From patchwork Fri Mar 23 03:38:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 26439 Received: (qmail 58385 invoked by alias); 23 Mar 2018 03:38:49 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 58324 invoked by uid 89); 23 Mar 2018 03:38:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=height, Forget, respond X-HELO: gateway24.websitewelcome.com Received: from gateway24.websitewelcome.com (HELO gateway24.websitewelcome.com) (192.185.50.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 Mar 2018 03:38:47 +0000 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 8A3E03D5E9 for ; Thu, 22 Mar 2018 22:38:46 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id zDXSeMrRBz11gzDXSexsTx; Thu, 22 Mar 2018 22:38:46 -0500 Received: from 174-29-60-18.hlrn.qwest.net ([174.29.60.18]:57164 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1ezDXS-0035f3-A9; Thu, 22 Mar 2018 22:38:46 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 2/2] Remove cleanups from prompt_for_continue Date: Thu, 22 Mar 2018 21:38:43 -0600 Message-Id: <20180323033843.29577-3-tom@tromey.com> In-Reply-To: <20180323033843.29577-1-tom@tromey.com> References: <20180323033843.29577-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1ezDXS-0035f3-A9 X-Source-Sender: 174-29-60-18.hlrn.qwest.net (bapiya.Home) [174.29.60.18]:57164 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This removes the cleanups from prompt_for_continue by the use of unique_xmalloc_ptr. gdb/ChangeLog 2018-03-22 Tom Tromey * 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 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. */