From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 300 invoked by alias); 19 Jul 2012 18:52:00 -0000 Received: (qmail 32759 invoked by uid 22791); 19 Jul 2012 18:52:00 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RCVD_IN_HOSTKARMA_W,SPF_HELO_PASS,TW_CP,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 19 Jul 2012 18:51:45 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q6JIpi0G026372 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 19 Jul 2012 14:51:44 -0400 Received: from host2.jankratochvil.net (ovpn-116-30.ams2.redhat.com [10.36.116.30]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q6JIpe1G026597 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 19 Jul 2012 14:51:43 -0400 Date: Thu, 19 Jul 2012 18:52:00 -0000 From: Jan Kratochvil To: Tom Tromey Cc: gdb-patches@sourceware.org Subject: Re: [PATCH 02/10] clean up allocation of bfd filenames Message-ID: <20120719185134.GA16054@host2.jankratochvil.net> References: <87r4s83lu5.fsf@fleche.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87r4s83lu5.fsf@fleche.redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-IsSubscribed: yes 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 X-SW-Source: 2012-07/txt/msg00370.txt.bz2 On Wed, 18 Jul 2012 21:34:10 +0200, Tom Tromey wrote: > BFD requires the user to allocate the file name for a BFD. > GDB does this inconsistently: sometimes the file name is malloc'd, > sometimes not. Sometimes it is freed, sometimes not. > > This patch adds a new function that reallocated the BFD's filename > using bfd_alloc. This ties the lifetime to the BFD and removes the > need to free the filename when closing the BFD. [...] > +void > +gdb_bfd_stash_filename (struct bfd *abfd) > +{ > + char *name = bfd_get_filename (abfd); > + char *data; > + > + data = bfd_alloc (abfd, strlen (name) + 1); > + strcpy (data, name); > + > + /* Unwarranted chumminess with BFD. */ > + abfd->filename = data; > +} Would not it be worth propose this bfd filename memory storage globally in bfd/ ? Thanks, Jan