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] Remove the last cleanup from regcache.c


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

commit 6c3e20f177102519cf4f8b3c7e7e17996ed7cd7f
Author: Tom Tromey <tom@tromey.com>
Date:   Sat Sep 23 15:54:36 2017 -0600

    Remove the last cleanup from regcache.c
    
    This removes the last cleanup from regcache.c by changing one function
    to use std::string.
    
    gdb/ChangeLog
    2017-09-25  Tom Tromey  <tom@tromey.com>
    
    	* regcache.c (regcache::dump): Use string_printf.

Diff:
---
 gdb/ChangeLog  |  4 ++++
 gdb/regcache.c | 11 ++++-------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 2fb2af1..0b9aea2 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2017-09-25  Tom Tromey  <tom@tromey.com>
 
+	* regcache.c (regcache::dump): Use string_printf.
+
+2017-09-25  Tom Tromey  <tom@tromey.com>
+
 	* regcache.c (class regcache_invalidator): New.
 	(struct register_to_invalidate): Remove.
 	(make_cleanup_regcache_invalidate): Remove.
diff --git a/gdb/regcache.c b/gdb/regcache.c
index 3dae6f7..96a4947 100644
--- a/gdb/regcache.c
+++ b/gdb/regcache.c
@@ -1350,7 +1350,6 @@ reg_flush_command (char *command, int from_tty)
 void
 regcache::dump (ui_file *file, enum regcache_dump_what what_to_dump)
 {
-  struct cleanup *cleanups = make_cleanup (null_cleanup, NULL);
   struct gdbarch *gdbarch = m_descr->gdbarch;
   int regnum;
   int footnote_nr = 0;
@@ -1442,6 +1441,7 @@ regcache::dump (ui_file *file, enum regcache_dump_what what_to_dump)
       /* Type.  */
       {
 	const char *t;
+	std::string name_holder;
 
 	if (regnum < 0)
 	  t = "Type";
@@ -1452,13 +1452,11 @@ regcache::dump (ui_file *file, enum regcache_dump_what what_to_dump)
 	    t = TYPE_NAME (register_type (arch (), regnum));
 	    if (t == NULL)
 	      {
-		char *n;
-
 		if (!footnote_register_type_name_null)
 		  footnote_register_type_name_null = ++footnote_nr;
-		n = xstrprintf ("*%d", footnote_register_type_name_null);
-		make_cleanup (xfree, n);
-		t = n;
+		name_holder = string_printf ("*%d",
+					     footnote_register_type_name_null);
+		t = name_holder.c_str ();
 	      }
 	    /* Chop a leading builtin_type.  */
 	    if (startswith (t, blt))
@@ -1592,7 +1590,6 @@ regcache::dump (ui_file *file, enum regcache_dump_what what_to_dump)
     fprintf_unfiltered (file, 
 			"*%d: Register type's name NULL.\n",
 			footnote_register_type_name_null);
-  do_cleanups (cleanups);
 }
 
 static void


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