From patchwork Fri Feb 9 12:55:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 25884 Received: (qmail 41927 invoked by alias); 9 Feb 2018 12:55:59 -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 41000 invoked by uid 89); 9 Feb 2018 12:55:58 -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.145.113) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 09 Feb 2018 12:55:57 +0000 Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway32.websitewelcome.com (Postfix) with ESMTP id 691744F47 for ; Fri, 9 Feb 2018 06:55:56 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id k8DcerhoumzEzk8Dceu005; Fri, 09 Feb 2018 06:55:56 -0600 Received: from 174-29-33-254.hlrn.qwest.net ([174.29.33.254]:36716 helo=pokyo.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1ek8Dc-000nMH-6V; Fri, 09 Feb 2018 06:55:56 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA 2/2] Use gdb::unique_xmalloc_ptr in auto_load_section_scripts Date: Fri, 9 Feb 2018 05:55:53 -0700 Message-Id: <20180209125553.7392-3-tom@tromey.com> In-Reply-To: <20180209125553.7392-1-tom@tromey.com> References: <20180209125553.7392-1-tom@tromey.com> X-BWhitelist: no X-Source-L: No X-Exim-ID: 1ek8Dc-000nMH-6V X-Source-Sender: 174-29-33-254.hlrn.qwest.net (pokyo.Home) [174.29.33.254]:36716 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes This changes auto_load_section_scripts to use gdb::unique_xmalloc_ptr, allowing the removal of a cleanup. 2018-02-09 Tom Tromey * auto-load.c (auto_load_section_scripts): Use gdb::unique_xmalloc_ptr. --- gdb/ChangeLog | 5 +++++ gdb/auto-load.c | 6 ++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index adc3d19d3b..9e03aa2908 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,10 @@ 2018-02-09 Tom Tromey + * auto-load.c (auto_load_section_scripts): Use + gdb::unique_xmalloc_ptr. + +2018-02-09 Tom Tromey + * auto-load.c (execute_script_contents): Use std::string. 2018-02-09 Joel Brobecker diff --git a/gdb/auto-load.c b/gdb/auto-load.c index 1f3d366a56..b79341faf6 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -1153,13 +1153,11 @@ auto_load_section_scripts (struct objfile *objfile, const char *section_name) section_name, bfd_get_filename (abfd)); else { - struct cleanup *cleanups; - char *p = (char *) data; + gdb::unique_xmalloc_ptr data_holder (data); - cleanups = make_cleanup (xfree, p); + char *p = (char *) data; source_section_scripts (objfile, section_name, p, p + bfd_get_section_size (scripts_sect)); - do_cleanups (cleanups); } }