From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 63663 invoked by alias); 3 Sep 2018 19:02:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 63654 invoked by uid 89); 3 Sep 2018 19:02:55 -0000 Authentication-Results: sourceware.org; auth=none 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_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: gateway33.websitewelcome.com Received: from gateway33.websitewelcome.com (HELO gateway33.websitewelcome.com) (192.185.146.85) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 03 Sep 2018 19:02:53 +0000 Received: from cm12.websitewelcome.com (cm12.websitewelcome.com [100.42.49.8]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 7CE009253A for ; Mon, 3 Sep 2018 14:02:52 -0500 (CDT) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id wu7gfSZXTSjJAwu7gf6X6E; Mon, 03 Sep 2018 14:02:52 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=kICtXNkzVxFiw9N2YtTRlKoC3RQ6YNGykDTDTf2tP4k=; b=opFIqqzPnfHsPBWpWPX1vNxo6g 5WFcryNlsFYXMouJM0CKZhhJa1I8c/z06PCfPxaiifN8baNMkd9ReRl10pJ8JfNlkT4sjDuVxlbe1 5VJuERc15MWZm1mJvlB9DYjjh; Received: from 75-166-85-72.hlrn.qwest.net ([75.166.85.72]:58120 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.91) (envelope-from ) id 1fwu7g-002juS-7u; Mon, 03 Sep 2018 14:02:52 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/4] Remove cleanup from add_path Date: Mon, 03 Sep 2018 19:02:00 -0000 Message-Id: <20180903190250.11599-2-tom@tromey.com> In-Reply-To: <20180903190250.11599-1-tom@tromey.com> References: <20180903190250.11599-1-tom@tromey.com> X-SW-Source: 2018-09/txt/msg00026.txt.bz2 This removes a cleanup from add_path, replacing it with a use of gdb::unique_xmalloc_ptr. Note that this declaration had to be hoisted somewhat, to avoid inteference from the "goto"s in this function. gdb/ChangeLog 2018-09-03 Tom Tromey * source.c (add_path): Use gdb::unique_xmalloc_ptr. --- gdb/ChangeLog | 4 ++++ gdb/source.c | 16 +++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/gdb/source.c b/gdb/source.c index cc5c46d0a7b..ec0ea3b81e3 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -479,13 +479,12 @@ add_path (const char *dirname, char **which_path, int parse_separators) else dir_vec.emplace_back (xstrdup (dirname)); - struct cleanup *back_to = make_cleanup (null_cleanup, NULL); - for (const gdb::unique_xmalloc_ptr &name_up : dir_vec) { char *name = name_up.get (); char *p; struct stat st; + gdb::unique_xmalloc_ptr new_name_holder; /* Spaces and tabs will have been removed by buildargv(). NAME is the start of the directory. @@ -531,16 +530,17 @@ add_path (const char *dirname, char **which_path, int parse_separators) } if (name[0] == '~') - name = tilde_expand (name); + new_name_holder.reset (tilde_expand (name)); #ifdef HAVE_DOS_BASED_FILE_SYSTEM else if (IS_ABSOLUTE_PATH (name) && p == name + 2) /* "d:" => "d:." */ - name = concat (name, ".", (char *)NULL); + new_name_holder.reset (concat (name, ".", (char *) NULL)); #endif else if (!IS_ABSOLUTE_PATH (name) && name[0] != '$') - name = concat (current_directory, SLASH_STRING, name, (char *)NULL); + new_name_holder.reset (concat (current_directory, SLASH_STRING, name, + (char *) NULL)); else - name = savestring (name, p - name); - make_cleanup (xfree, name); + new_name_holder.reset (savestring (name, p - name)); + name = new_name_holder.get (); /* Unless it's a variable, check existence. */ if (name[0] != '$') @@ -630,8 +630,6 @@ add_path (const char *dirname, char **which_path, int parse_separators) skip_dup: ; } - - do_cleanups (back_to); } -- 2.13.6