From patchwork Tue Jul 25 17:20:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 21775 Received: (qmail 46424 invoked by alias); 25 Jul 2017 17:27:44 -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 46386 invoked by uid 89); 25 Jul 2017 17:27:43 -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, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gproxy10-pub.mail.unifiedlayer.com Received: from gproxy10-pub.mail.unifiedlayer.com (HELO gproxy10-pub.mail.unifiedlayer.com) (69.89.20.226) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 25 Jul 2017 17:27:41 +0000 Received: from cmgw2 (unknown [10.0.90.83]) by gproxy10.mail.unifiedlayer.com (Postfix) with ESMTP id 143611408FE for ; Tue, 25 Jul 2017 11:21:22 -0600 (MDT) Received: from box522.bluehost.com ([74.220.219.122]) by cmgw2 with id p5MJ1v00f2f2jeq015MMJg; Tue, 25 Jul 2017 11:21:22 -0600 X-Authority-Analysis: v=2.2 cv=IqBuSP3g c=1 sm=1 tr=0 a=GsOEXm/OWkKvwdLVJsfwcA==:117 a=GsOEXm/OWkKvwdLVJsfwcA==:17 a=G3gG6ho9WtcA:10 a=zstS-IiYAAAA:8 a=VvXDCs-xsNQiopGqF0kA:9 a=4G6NA9xxw8l3yy4pmD5M:22 Received: from 174-29-39-24.hlrn.qwest.net ([174.29.39.24]:55470 helo=bapiya.Home) by box522.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.87) (envelope-from ) id 1da3WI-0015gW-FR; Tue, 25 Jul 2017 11:21:18 -0600 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [RFA v2 14/24] Use unique_xmalloc_ptr in jit.c Date: Tue, 25 Jul 2017 11:20:57 -0600 Message-Id: <20170725172107.9799-15-tom@tromey.com> In-Reply-To: <20170725172107.9799-1-tom@tromey.com> References: <20170725172107.9799-1-tom@tromey.com> X-BWhitelist: no X-Exim-ID: 1da3WI-0015gW-FR X-Source-Sender: 174-29-39-24.hlrn.qwest.net (bapiya.Home) [174.29.39.24]:55470 X-Source-Auth: tom+tromey.com X-Email-Count: 15 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTIyLmJsdWVob3N0LmNvbQ== X-Local-Domain: yes This removes some cleanups from jit.c by using unique_xmalloc_ptr instead. ChangeLog 2017-07-25 Tom Tromey * jit.c (jit_reader_load_command): Use unique_xmalloc_ptr. --- gdb/ChangeLog | 4 ++++ gdb/jit.c | 20 ++++++-------------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 1ba2801..a08aa29 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,9 @@ 2017-07-25 Tom Tromey + * jit.c (jit_reader_load_command): Use unique_xmalloc_ptr. + +2017-07-25 Tom Tromey + * tui/tui-regs.c (tui_restore_gdbout): Remove. (tui_register_format): Use scoped_restore. diff --git a/gdb/jit.c b/gdb/jit.c index ddf1005..15b93fe 100644 --- a/gdb/jit.c +++ b/gdb/jit.c @@ -211,29 +211,21 @@ jit_reader_load (const char *file_name) static void jit_reader_load_command (char *args, int from_tty) { - char *so_name; - struct cleanup *prev_cleanup; - if (args == NULL) error (_("No reader name provided.")); - args = tilde_expand (args); - prev_cleanup = make_cleanup (xfree, args); + gdb::unique_xmalloc_ptr file (tilde_expand (args)); if (loaded_jit_reader != NULL) error (_("JIT reader already loaded. Run jit-reader-unload first.")); - if (IS_ABSOLUTE_PATH (args)) - so_name = args; - else - { - so_name = xstrprintf ("%s%s%s", jit_reader_dir, SLASH_STRING, args); - make_cleanup (xfree, so_name); - } + gdb::unique_xmalloc_ptr so_name; + if (!IS_ABSOLUTE_PATH (file.get ())) + file.reset (xstrprintf ("%s%s%s", jit_reader_dir, SLASH_STRING, + file.get ())); - loaded_jit_reader = jit_reader_load (so_name); + loaded_jit_reader = jit_reader_load (file.get ()); reinit_frame_cache (); jit_inferior_created_hook (); - do_cleanups (prev_cleanup); } /* Provides the jit-reader-unload command. */