dwarf2read: Replace copy_string usages with savestring
authorSimon Marchi <simon.marchi@ericsson.com>
Fri, 15 Sep 2017 14:41:34 +0000 (16:41 +0200)
committerSimon Marchi <simon.marchi@ericsson.com>
Fri, 15 Sep 2017 14:41:34 +0000 (16:41 +0200)
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
gdb/dwarf2read.c

index 7cbd161..86f1fb8 100644 (file)
@@ -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
index a123ea7..d97ef92 100644 (file)
@@ -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);