This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] ada: Use std::string in print_dynamic_range_bound


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=3ec5942fbf8501db10784b0dff7d24222a113728

commit 3ec5942fbf8501db10784b0dff7d24222a113728
Author: Simon Marchi <simon.marchi@ericsson.com>
Date:   Fri Oct 13 22:45:14 2017 -0400

    ada: Use std::string in print_dynamic_range_bound
    
    Replace this usage of GROW_VECT with an std::string.  I don't think
    there's a reason for this variable to be static, other than it was
    cumbersome to manage its lifetime (i.e. use a cleanup) before.
    
    Tested by comparing the gdb.ada/*.exp test results before and after the
    patch.
    
    gdb/ChangeLog:
    
    	* ada-typeprint.c (print_dynamic_range_bound): Use std::string.

Diff:
---
 gdb/ChangeLog       |  4 ++++
 gdb/ada-typeprint.c | 10 +++-------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 56f253e..cb0f989 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2017-10-13  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* ada-typeprint.c (print_dynamic_range_bound): Use std::string.
+
 2017-10-13  Yao Qi  <yao.qi@linaro.org>
 
 	* features/Makefile: Remove tic6x-*-expedite, add tic6x-expedite.
diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c
index 2224bb3..0d1f9dc 100644
--- a/gdb/ada-typeprint.c
+++ b/gdb/ada-typeprint.c
@@ -253,15 +253,11 @@ static void
 print_dynamic_range_bound (struct type *type, const char *name, int name_len,
 			   const char *suffix, struct ui_file *stream)
 {
-  static char *name_buf = NULL;
-  static size_t name_buf_len = 0;
   LONGEST B;
+  std::string name_buf (name, name_len);
+  name_buf += suffix;
 
-  GROW_VECT (name_buf, name_buf_len, name_len + strlen (suffix) + 1);
-  strncpy (name_buf, name, name_len);
-  strcpy (name_buf + name_len, suffix);
-
-  if (get_int_var_value (name_buf, B))
+  if (get_int_var_value (name_buf.c_str (), B))
     ada_print_scalar (type, B, stream);
   else
     fprintf_filtered (stream, "?");


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]