From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1930 invoked by alias); 4 Aug 2017 20:34:40 -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 1266 invoked by uid 89); 4 Aug 2017 20:34:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.2 spammy= 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; Fri, 04 Aug 2017 20:34:38 +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 v74KYV6O027077 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 4 Aug 2017 16:34:36 -0400 Received: by simark.ca (Postfix, from userid 112) id B6D551EA05; Fri, 4 Aug 2017 16:34:31 -0400 (EDT) Received: from simark.ca (localhost [127.0.0.1]) by simark.ca (Postfix) with ESMTP id 8F5521E5A6; Fri, 4 Aug 2017 16:34:30 -0400 (EDT) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 04 Aug 2017 20:34:00 -0000 From: Simon Marchi To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [RFA] Use gdb::unique_xmalloc_ptr when calling tilde_expand In-Reply-To: <7f9192116eeb22b959a56145e70ee2d4@polymtl.ca> References: <20170803214348.27356-1-tom@tromey.com> <87bmnv8n2y.fsf@tromey.com> <87h8xncl3t.fsf@pokyo> <7f9192116eeb22b959a56145e70ee2d4@polymtl.ca> Message-ID: <12e4ff13f71f3c44b6407e87b86ade08@polymtl.ca> X-Sender: simon.marchi@polymtl.ca User-Agent: Roundcube Webmail/1.3.0 X-Poly-FromMTA: (simark.ca [158.69.221.121]) at Fri, 4 Aug 2017 20:34:31 +0000 X-IsSubscribed: yes X-SW-Source: 2017-08/txt/msg00086.txt.bz2 On 2017-08-04 22:28, Simon Marchi wrote: > On 2017-08-04 19:13, Tom Tromey wrote: >> Simon> There is still a cleanup in reload_shared_libraries_1, so I >> don't >> Simon> think the do_cleanups should be removed. >> >> Ugh, sorry about that. >> >> That code is duplicating the bfd's file name. But I can't see why >> that's important. I think just removing the xstrdup and the >> make_cleanup is the right thing to do here. What do you think? >> >> Tom > > I don't see any reason either. > > Simon Actually, if we look at the code before you introduced gdb_bfd_ref_ptr, the lifetime of abfd was shorter than the required lifetime of the string. Since freeing the bfd frees the name internally, one option was to make a copy. With gdb_bfd_ref_ptr, the lifetime of abfd is long enough that we don't need the copy. Simon