Use ui_file_as_string in dwarf2_compute_name
authorPedro Alves <palves@redhat.com>
Tue, 8 Nov 2016 15:26:44 +0000 (15:26 +0000)
committerPedro Alves <palves@redhat.com>
Tue, 8 Nov 2016 15:26:44 +0000 (15:26 +0000)
gdb/ChangeLog:
2016-11-08  Pedro Alves  <palves@redhat.com>

* dwarf2read.c (dwarf2_compute_name): Use ui_file_as_string and
std::string.

gdb/ChangeLog
gdb/dwarf2read.c

index 274c681668156120eeb9157f339aabe69c5c5c64..dbf4eb3ec11d59cd185abea2c0fd0d8ec2059511 100644 (file)
@@ -1,3 +1,8 @@
+2016-11-08  Pedro Alves  <palves@redhat.com>
+
+       * dwarf2read.c (dwarf2_compute_name): Use ui_file_as_string and
+       std::string.
+
 2016-11-08  Pedro Alves  <palves@redhat.com>
 
        * mi/mi-main.c (print_variable_or_computed): Constify 'expression'
index c070cd74302298d69bf3d88ff124899d477b5f3a..6cc79ea30ebf3da6e22e26de2be7d9a2d4eed152 100644 (file)
@@ -8487,7 +8487,6 @@ dwarf2_compute_name (const char *name,
          long length;
          const char *prefix;
          struct ui_file *buf;
-         char *intermediate_name;
          const char *canonical_name = NULL;
 
          prefix = determine_prefix (die, cu);
@@ -8656,26 +8655,24 @@ dwarf2_compute_name (const char *name,
                }
            }
 
-         intermediate_name = ui_file_xstrdup (buf, &length);
+         std::string intermediate_name = ui_file_as_string (buf);
          ui_file_delete (buf);
 
          if (cu->language == language_cplus)
            canonical_name
-             = dwarf2_canonicalize_name (intermediate_name, cu,
+             = dwarf2_canonicalize_name (intermediate_name.c_str (), cu,
                                          &objfile->per_bfd->storage_obstack);
 
          /* If we only computed INTERMEDIATE_NAME, or if
             INTERMEDIATE_NAME is already canonical, then we need to
             copy it to the appropriate obstack.  */
-         if (canonical_name == NULL || canonical_name == intermediate_name)
+         if (canonical_name == NULL || canonical_name == intermediate_name.c_str ())
            name = ((const char *)
                    obstack_copy0 (&objfile->per_bfd->storage_obstack,
-                                  intermediate_name,
-                                  strlen (intermediate_name)));
+                                  intermediate_name.c_str (),
+                                  intermediate_name.length ()));
          else
            name = canonical_name;
-
-         xfree (intermediate_name);
        }
     }