public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 2/2] Remove cleanups from prompt_for_continue
Date: Fri, 23 Mar 2018 03:38:00 -0000	[thread overview]
Message-ID: <20180323033843.29577-3-tom@tromey.com> (raw)
In-Reply-To: <20180323033843.29577-1-tom@tromey.com>

This removes the cleanups from prompt_for_continue by the use of
unique_xmalloc_ptr.

gdb/ChangeLog
2018-03-22  Tom Tromey  <tom@tromey.com>

	* utils.c (prompt_for_continue): Use unique_xmalloc_ptr.
---
 gdb/ChangeLog | 4 ++++
 gdb/utils.c   | 9 ++-------
 2 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/gdb/utils.c b/gdb/utils.c
index 3886efd840..ee31f39661 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -1479,9 +1479,7 @@ set_screen_width_and_height (int width, int height)
 static void
 prompt_for_continue (void)
 {
-  char *ignore;
   char cont_prompt[120];
-  struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
   /* Used to add duration we waited for user to respond to
      prompt_for_continue_wait_time.  */
   using namespace std::chrono;
@@ -1504,8 +1502,7 @@ prompt_for_continue (void)
 
   /* Call gdb_readline_wrapper, not readline, in order to keep an
      event loop running.  */
-  ignore = gdb_readline_wrapper (cont_prompt);
-  make_cleanup (xfree, ignore);
+  gdb::unique_xmalloc_ptr<char> ignore (gdb_readline_wrapper (cont_prompt));
 
   /* Add time spend in this routine to prompt_for_continue_wait_time.  */
   prompt_for_continue_wait_time += steady_clock::now () - prompt_started;
@@ -1515,7 +1512,7 @@ prompt_for_continue (void)
 
   if (ignore != NULL)
     {
-      char *p = ignore;
+      char *p = ignore.get ();
 
       while (*p == ' ' || *p == '\t')
 	++p;
@@ -1529,8 +1526,6 @@ prompt_for_continue (void)
   reinitialize_more_filter ();
 
   dont_repeat ();		/* Forget prev cmd -- CR won't repeat it.  */
-
-  do_cleanups (old_chain);
 }
 
 /* Initialize timer to keep track of how long we waited for the user.  */
-- 
2.13.6

  parent reply	other threads:[~2018-03-23  3:38 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-23  3:38 [RFA 0/2] two simple cleanup removals Tom Tromey
2018-03-23  3:38 ` [RFA 1/2] Remove cleanups from gdb_readline_wrapper Tom Tromey
2018-03-24 11:19   ` Pedro Alves
2018-03-25 16:19     ` Tom Tromey
2018-03-23  3:38 ` Tom Tromey [this message]
2018-03-24 11:19   ` [RFA 2/2] Remove cleanups from prompt_for_continue Pedro Alves

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=20180323033843.29577-3-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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).