Use std::string in dwarf2read.c
authorTom Tromey <tromey@adacore.com>
Thu, 31 Oct 2019 16:46:18 +0000 (10:46 -0600)
committerTom Tromey <tromey@adacore.com>
Wed, 8 Jan 2020 18:17:18 +0000 (11:17 -0700)
This replaces two instances of manual string management in
dwarf2read.c with std::string.

gdb/ChangeLog
2020-01-08  Tom Tromey  <tromey@adacore.com>

* dwarf2read.c (parse_macro_definition): Use std::string.
(parse_macro_definition): Likewise.

Change-Id: Iec437100105484aa4a116fb5d651d7ed52ee9d81

gdb/ChangeLog
gdb/dwarf2read.c

index 118d6d7a2ba6f9c0e33c1cbc7d59830ecc7de22a..9733a106222f48b8e41c7ff3516fcb7a8f68a733 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-08  Tom Tromey  <tromey@adacore.com>
+
+       * dwarf2read.c (parse_macro_definition): Use std::string.
+       (parse_macro_definition): Likewise.
+
 2020-01-08  Tom Tromey  <tromey@adacore.com>
 
        * dwarf2read.c (abbrev_table_read_table): Use std::vector.
index 5a194f4e27b4e891e1f2844fbe29884c47f8cdb3..40af0b975ba85d22058cd0c25002e2573494bb02 100644 (file)
@@ -24570,7 +24570,7 @@ parse_macro_definition (struct macro_source_file *file, int line,
     {
       /* It's an object-like macro.  */
       int name_len = p - body;
-      char *name = savestring (body, name_len);
+      std::string name (body, name_len);
       const char *replacement;
 
       if (*p == ' ')
@@ -24581,14 +24581,12 @@ parse_macro_definition (struct macro_source_file *file, int line,
           replacement = body + name_len;
         }
 
-      macro_define_object (file, line, name, replacement);
-
-      xfree (name);
+      macro_define_object (file, line, name.c_str (), replacement);
     }
   else if (*p == '(')
     {
       /* It's a function-like macro.  */
-      char *name = savestring (body, p - body);
+      std::string name (body, p - body);
       int argc = 0;
       int argv_size = 1;
       char **argv = XNEWVEC (char *, argv_size);
@@ -24637,14 +24635,14 @@ parse_macro_definition (struct macro_source_file *file, int line,
 
           if (*p == ' ')
             /* Perfectly formed definition, no complaints.  */
-            macro_define_function (file, line, name,
+            macro_define_function (file, line, name.c_str (),
                                    argc, (const char **) argv,
                                    p + 1);
           else if (*p == '\0')
             {
               /* Complain, but do define it.  */
              dwarf2_macro_malformed_definition_complaint (body);
-              macro_define_function (file, line, name,
+              macro_define_function (file, line, name.c_str (),
                                      argc, (const char **) argv,
                                      p);
             }
@@ -24656,7 +24654,6 @@ parse_macro_definition (struct macro_source_file *file, int line,
         /* Just complain.  */
        dwarf2_macro_malformed_definition_complaint (body);
 
-      xfree (name);
       {
         int i;
 
This page took 0.033485 seconds and 4 git commands to generate.