From patchwork Mon Aug 20 01:50:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 28965 Received: (qmail 86256 invoked by alias); 20 Aug 2018 01:50:58 -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 86194 invoked by uid 89); 20 Aug 2018 01:50:57 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.2 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_SOFTFAIL autolearn=ham version=3.3.2 spammy=Hx-languages-length:1069, management X-HELO: barracuda.ebox.ca Received: from barracuda.ebox.ca (HELO barracuda.ebox.ca) (96.127.255.19) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 20 Aug 2018 01:50:56 +0000 Received: from smtp.ebox.ca (smtp.electronicbox.net [96.127.255.82]) by barracuda.ebox.ca with ESMTP id pJKwlj4LRgjIzq7f (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sun, 19 Aug 2018 21:50:52 -0400 (EDT) Received: from simark.lan (unknown [192.222.164.54]) by smtp.ebox.ca (Postfix) with ESMTP id C60F8441D65; Sun, 19 Aug 2018 21:50:52 -0400 (EDT) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 1/2] Make ada-lang.c::add_angle_brackets return an std::string Date: Sun, 19 Aug 2018 21:50:50 -0400 Message-Id: <20180820015051.31574-1-simon.marchi@polymtl.ca> X-IsSubscribed: yes This removes the need for manual memory management. It may also be a bit more efficient, since the returned string can be moved all the way into the destination, in ada_lookup_name_info::matches. gdb/ChangeLog: * ada-lang.c (add_angle_brackets): Return std::string. --- gdb/ada-lang.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index db5334dd1e00..d9d3087642bc 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -541,17 +541,12 @@ ada_unqualified_name (const char *decoded_name) return result; } -/* Return a string starting with '<', followed by STR, and '>'. - The result is good until the next call. */ +/* Return a string starting with '<', followed by STR, and '>'. */ -static char * +static std::string add_angle_brackets (const char *str) { - static char *result = NULL; - - xfree (result); - result = xstrprintf ("<%s>", str); - return result; + return string_printf ("<%s>", str); } static const char *