Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 5/5] Remove the last cleanup from regcache.c
Date: Sun, 24 Sep 2017 02:46:00 -0000	[thread overview]
Message-ID: <20170924024608.4346-6-tom@tromey.com> (raw)
In-Reply-To: <20170924024608.4346-1-tom@tromey.com>

This removes the last cleanup from regcache.c by changing one function
to use std::string.

ChangeLog
2017-09-23  Tom Tromey  <tom@tromey.com>

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

diff --git a/gdb/regcache.c b/gdb/regcache.c
index 46d8cfb..0eefec6 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
-- 
2.9.5


  parent reply	other threads:[~2017-09-24  2:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-24  2:46 [RFA 0/5] remove cleanups from regcache Tom Tromey
2017-09-24  2:46 ` [RFA 2/5] Remove regcache_xfree Tom Tromey
2017-09-24  2:46 ` [RFA 3/5] Remove make_cleanup_regcache_xfree Tom Tromey
2017-09-24  2:46 ` [RFA 1/5] Remove regcache_xmalloc Tom Tromey
2017-09-26  4:55   ` Tom Tromey
2017-09-26  5:10     ` Sergio Durigan Junior
2017-09-24  2:46 ` [RFA 4/5] Remove make_cleanup_regcache_invalidate Tom Tromey
2017-09-25 20:04   ` Yao Qi
2017-09-26  1:36     ` Tom Tromey
2017-09-26  1:56       ` Tom Tromey
2017-09-24  2:46 ` Tom Tromey [this message]
2017-09-26  0:08 ` [RFA 0/5] remove cleanups from regcache Yao Qi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170924024608.4346-6-tom@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox