From patchwork Thu Jun 7 22:44:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 27699 Received: (qmail 90580 invoked by alias); 7 Jun 2018 22:44:32 -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 90558 invoked by uid 89); 7 Jun 2018 22:44:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-23.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_HELO_PASS, UNWANTED_LANGUAGE_BODY autolearn=ham version=3.3.2 spammy=20837 X-HELO: gateway23.websitewelcome.com Received: from gateway23.websitewelcome.com (HELO gateway23.websitewelcome.com) (192.185.49.179) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 07 Jun 2018 22:44:30 +0000 Received: from cm17.websitewelcome.com (cm17.websitewelcome.com [100.42.49.20]) by gateway23.websitewelcome.com (Postfix) with ESMTP id A4A7241E7 for ; Thu, 7 Jun 2018 17:44:29 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id R3dtfkRJ8PvAdR3dtfx75U; Thu, 07 Jun 2018 17:44:29 -0500 X-Authority-Reason: nr=8 Received: from 75-166-19-45.hlrn.qwest.net ([75.166.19.45]:34642 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fR3dt-001b18-Bf; Thu, 07 Jun 2018 17:44:29 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 2/2] Remove last cleanup from btrace code Date: Thu, 7 Jun 2018 16:44:26 -0600 Message-Id: <20180607224426.6403-3-tom@tromey.com> In-Reply-To: <20180607224426.6403-1-tom@tromey.com> References: <20180607224426.6403-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1fR3dt-001b18-Bf X-Source-Sender: 75-166-19-45.hlrn.qwest.net (bapiya.Home) [75.166.19.45]:34642 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This removes the last cleanup from btrace.c, replacing it with a use of unique_xmalloc_ptr. 2018-06-07 Tom Tromey * btrace.c (parse_xml_raw): Use gdb::unique_xmalloc_ptr. --- gdb/ChangeLog | 4 ++++ gdb/btrace.c | 11 ++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/gdb/btrace.c b/gdb/btrace.c index 690770572e8..b8894a24ba0 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -2056,8 +2056,7 @@ static void parse_xml_raw (struct gdb_xml_parser *parser, const char *body_text, gdb_byte **pdata, size_t *psize) { - struct cleanup *cleanup; - gdb_byte *data, *bin; + gdb_byte *bin; size_t len, size; len = strlen (body_text); @@ -2066,8 +2065,8 @@ parse_xml_raw (struct gdb_xml_parser *parser, const char *body_text, size = len / 2; - bin = data = (gdb_byte *) xmalloc (size); - cleanup = make_cleanup (xfree, data); + gdb::unique_xmalloc_ptr data ((gdb_byte *) xmalloc (size)); + bin = data.get (); /* We use hex encoding - see common/rsp-low.h. */ while (len > 0) @@ -2084,9 +2083,7 @@ parse_xml_raw (struct gdb_xml_parser *parser, const char *body_text, len -= 2; } - discard_cleanups (cleanup); - - *pdata = data; + *pdata = data.release (); *psize = size; }