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] Use ui_file_as_string in dwarf2_compute_name


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

commit 322a851675234b3c16be6dd5035b07f5e3410ec7
Author: Pedro Alves <palves@redhat.com>
Date:   Tue Nov 8 15:26:44 2016 +0000

    Use ui_file_as_string in dwarf2_compute_name
    
    gdb/ChangeLog:
    2016-11-08  Pedro Alves  <palves@redhat.com>
    
    	* dwarf2read.c (dwarf2_compute_name): Use ui_file_as_string and
    	std::string.

Diff:
---
 gdb/ChangeLog    |  5 +++++
 gdb/dwarf2read.c | 13 +++++--------
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 274c681..dbf4eb3 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 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'
 	parameter.
 	(mi_cmd_trace_frame_collected): Call encode_actions instead of
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index c070cd7..6cc79ea 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -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);
 	}
     }


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