From patchwork Sat May 19 15:17:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27334 Received: (qmail 93904 invoked by alias); 19 May 2018 15:18:06 -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 93875 invoked by uid 89); 19 May 2018 15:18:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.9 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= X-HELO: gateway32.websitewelcome.com Received: from gateway32.websitewelcome.com (HELO gateway32.websitewelcome.com) (192.185.144.98) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 19 May 2018 15:18:03 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway32.websitewelcome.com (Postfix) with ESMTP id 0B63E6B5FF15 for ; Sat, 19 May 2018 10:18:02 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id K3cQf72DPBcCXK3cQf2Qfr; Sat, 19 May 2018 10:18:02 -0500 X-Authority-Reason: nr=8 Received: from 174-29-44-154.hlrn.qwest.net ([174.29.44.154]:36436 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1fK3cP-002N1T-9u; Sat, 19 May 2018 10:18:01 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA] Remove a cleanup from trace_dump_actions Date: Sat, 19 May 2018 09:17:57 -0600 Message-Id: <20180519151757.18031-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fK3cP-002N1T-9u X-Source-Sender: 174-29-44-154.hlrn.qwest.net (bapiya.Home) [174.29.44.154]:36436 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This changes trace_dump_actions to use std::string, removing a cleanup. Tested by the buildbot. gdb/ChangeLog 2018-05-19 Tom Tromey * tracepoint.c (trace_dump_actions): Use std::string. --- gdb/ChangeLog | 4 ++++ gdb/tracepoint.c | 20 ++++---------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index e170d704bc..d83af78dd5 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -2679,9 +2679,6 @@ trace_dump_actions (struct command_line *action, STEPPING_ACTIONS should be equal. */ if (stepping_frame == stepping_actions) { - char *cmd = NULL; - struct cleanup *old_chain - = make_cleanup (free_current_contents, &cmd); int trace_string = 0; if (*action_exp == '/') @@ -2706,20 +2703,13 @@ trace_dump_actions (struct command_line *action, info_args_command (NULL, from_tty); else { /* variable */ + std::string contents; + const char *cmd = action_exp; if (next_comma != NULL) { size_t len = next_comma - action_exp; - - cmd = (char *) xrealloc (cmd, len + 1); - memcpy (cmd, action_exp, len); - cmd[len] = 0; - } - else - { - size_t len = strlen (action_exp); - - cmd = (char *) xrealloc (cmd, len + 1); - memcpy (cmd, action_exp, len + 1); + contents = std::string (action_exp, len); + cmd = contents.c_str (); } printf_filtered ("%s = ", cmd); @@ -2729,8 +2719,6 @@ trace_dump_actions (struct command_line *action, action_exp = next_comma; } while (action_exp && *action_exp == ','); - - do_cleanups (old_chain); } } }