From patchwork Tue Oct 10 20:25:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 23465 Received: (qmail 72589 invoked by alias); 10 Oct 2017 20:26:08 -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 72570 invoked by uid 89); 10 Oct 2017 20:26:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=scroll, management X-HELO: gproxy2-pub.mail.unifiedlayer.com Received: from gproxy2-pub.mail.unifiedlayer.com (HELO gproxy2-pub.mail.unifiedlayer.com) (69.89.18.3) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 10 Oct 2017 20:26:06 +0000 Received: from CMOut01 (unknown [10.0.90.82]) by gproxy2.mail.unifiedlayer.com (Postfix) with ESMTP id 0C5B91E0938 for ; Tue, 10 Oct 2017 14:26:05 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by CMOut01 with id KwS11w01h2f2jeq01wS4qM; Tue, 10 Oct 2017 14:26:05 -0600 X-Authority-Analysis: v=2.2 cv=K4VSJ2eI c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=02M-m0pO-4AA:10 a=zstS-IiYAAAA:8 a=0kqOJPp8_elqr4W2wX4A:9 a=xnG0Pf39KHMOlogc:21 a=mA3j8CqRpUcT6whY:21 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 184-96-33-178.hlrn.qwest.net ([184.96.33.178]:48120 helo=bapiya.localdomain) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1e216H-003F10-OW; Tue, 10 Oct 2017 14:26:01 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Remove cleanups from TUI Date: Tue, 10 Oct 2017 14:25:58 -0600 Message-Id: <20171010202558.29742-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1e216H-003F10-OW X-Source-Sender: 184-96-33-178.hlrn.qwest.net (bapiya.localdomain) [184.96.33.178]:48120 X-Source-Auth: tom+tromey.com X-Email-Count: 1 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This removes the last cleanups from the TUI, by using std::string rather than manual memory management. Regression tested against gdb.tui/*.exp on Fedora 26 x86-64. gdb/ChangeLog 2017-10-09 Tom Tromey * tui/tui-win.c (tui_set_win_height, parse_scrolling_args): Use std::string. * tui/tui-layout.c (enum tui_status): Use std::string. --- gdb/ChangeLog | 6 ++++++ gdb/tui/tui-layout.c | 11 ++++------- gdb/tui/tui-win.c | 15 +++++---------- 3 files changed, 15 insertions(+), 17 deletions(-) diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index eab1ab6336..fe68331b5b 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -404,15 +404,13 @@ tui_set_layout_by_name (const char *layout_name) if (layout_name != (char *) NULL) { int i; - char *buf_ptr; enum tui_layout_type new_layout = UNDEFINED_LAYOUT; enum tui_layout_type cur_layout = tui_current_layout (); - struct cleanup *old_chain; - buf_ptr = (char *) xstrdup (layout_name); - for (i = 0; (i < strlen (layout_name)); i++) - buf_ptr[i] = toupper (buf_ptr[i]); - old_chain = make_cleanup (xfree, buf_ptr); + std::string copy = layout_name; + for (i = 0; i < copy.size (); i++) + copy[i] = toupper (copy[i]); + const char *buf_ptr = copy.c_str (); /* First check for ambiguous input. */ if (strlen (buf_ptr) <= 1 && *buf_ptr == 'S') @@ -450,7 +448,6 @@ tui_set_layout_by_name (const char *layout_name) tui_set_layout (new_layout); } } - do_cleanups (old_chain); } else status = TUI_FAILURE; diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index cb8e475b72..a7ab960f40 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -1165,14 +1165,13 @@ tui_set_win_height (char *arg, int from_tty) tui_enable (); if (arg != (char *) NULL) { - char *buf = xstrdup (arg); + std::string copy = arg; + char *buf = ©[0]; char *buf_ptr = buf; char *wname = NULL; int new_height, i; struct tui_win_info *win_info; - struct cleanup *old_chain; - old_chain = make_cleanup (xfree, buf); wname = buf_ptr; buf_ptr = strchr (buf_ptr, ' '); if (buf_ptr != (char *) NULL) @@ -1234,8 +1233,6 @@ The window name specified must be valid and visible.\n")); } else printf_filtered (WIN_HEIGHT_USAGE); - - do_cleanups (old_chain); } else printf_filtered (WIN_HEIGHT_USAGE); @@ -1661,12 +1658,11 @@ parse_scrolling_args (char *arg, window name arg. */ if (arg != (char *) NULL) { - char *buf, *buf_ptr; - struct cleanup *old_chain; + char *buf_ptr; /* Process the number of lines to scroll. */ - buf = buf_ptr = xstrdup (arg); - old_chain = make_cleanup (xfree, buf); + std::string copy = arg; + buf_ptr = ©[0]; if (isdigit (*buf_ptr)) { char *num_str; @@ -1713,6 +1709,5 @@ The window name specified must be valid and visible.\n")); else if (*win_to_scroll == TUI_CMD_WIN) *win_to_scroll = (tui_source_windows ())->list[0]; } - do_cleanups (old_chain); } }