This is the mail archive of the gdb-patches@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]

[pushed] dwarf2read: Replace copy_string usages with savestring


copy_string does the exact same thing as savestring, so replace the
usages of the former with the latter.

gdb/ChangeLog:

	* dwarf2read.c (copy_string): Remove.
	(parse_macro_definition): Replace copy_string with savestring.
---
 gdb/ChangeLog    |  5 +++++
 gdb/dwarf2read.c | 20 +++-----------------
 2 files changed, 8 insertions(+), 17 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7cbd161..86f1fb8 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2017-09-15  Simon Marchi  <simon.marchi@ericsson.com>
+
+	* dwarf2read.c (copy_string): Remove.
+	(parse_macro_definition): Replace copy_string with savestring.
+
 2017-09-15  Yao Qi  <yao.qi@linaro.org>
 
 	* configure.tgt (i[34567]86-*-darwin*): Append amd64.o to
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index a123ea7..d97ef92 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -21685,20 +21685,6 @@ macro_start_file (int file, int line,
   return current_file;
 }
 
-
-/* Copy the LEN characters at BUF to a xmalloc'ed block of memory,
-   followed by a null byte.  */
-static char *
-copy_string (const char *buf, int len)
-{
-  char *s = (char *) xmalloc (len + 1);
-
-  memcpy (s, buf, len);
-  s[len] = '\0';
-  return s;
-}
-
-
 static const char *
 consume_improper_spaces (const char *p, const char *body)
 {
@@ -21758,7 +21744,7 @@ parse_macro_definition (struct macro_source_file *file, int line,
     {
       /* It's an object-like macro.  */
       int name_len = p - body;
-      char *name = copy_string (body, name_len);
+      char *name = savestring (body, name_len);
       const char *replacement;
 
       if (*p == ' ')
@@ -21776,7 +21762,7 @@ parse_macro_definition (struct macro_source_file *file, int line,
   else if (*p == '(')
     {
       /* It's a function-like macro.  */
-      char *name = copy_string (body, p - body);
+      char *name = savestring (body, p - body);
       int argc = 0;
       int argv_size = 1;
       char **argv = XNEWVEC (char *, argv_size);
@@ -21805,7 +21791,7 @@ parse_macro_definition (struct macro_source_file *file, int line,
                   argv = XRESIZEVEC (char *, argv, argv_size);
                 }
 
-              argv[argc++] = copy_string (arg_start, p - arg_start);
+              argv[argc++] = savestring (arg_start, p - arg_start);
             }
 
           p = consume_improper_spaces (p, body);
-- 
2.7.4


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