From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 111624 invoked by alias); 26 Aug 2018 16:43:27 -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 111613 invoked by uid 89); 26 Aug 2018 16:43:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy=management X-HELO: smtp.polymtl.ca Received: from smtp.polymtl.ca (HELO smtp.polymtl.ca) (132.207.4.11) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 26 Aug 2018 16:43:26 +0000 Received: from simark.ca (simark.ca [158.69.221.121]) (authenticated bits=0) by smtp.polymtl.ca (8.14.7/8.14.7) with ESMTP id w7QGhJaZ006202 (version=TLSv1/SSLv3 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Sun, 26 Aug 2018 12:43:24 -0400 Received: from [10.0.0.11] (unknown [192.222.164.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 43BE71E47D for ; Sun, 26 Aug 2018 12:43:19 -0400 (EDT) Subject: Re: [PATCH 1/2] Make ada-lang.c::add_angle_brackets return an std::string To: gdb-patches@sourceware.org References: <20180820015051.31574-1-simon.marchi@polymtl.ca> From: Simon Marchi Message-ID: <68984db8-4731-b132-53a6-3d03509699e5@polymtl.ca> Date: Sun, 26 Aug 2018 16:43:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20180820015051.31574-1-simon.marchi@polymtl.ca> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg00628.txt.bz2 On 2018-08-19 9:50 p.m., Simon Marchi wrote: > 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 * > I pushed these two patches. Simon