This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 02/10] clean up allocation of bfd filenames
- From: Jan Kratochvil <jan dot kratochvil at redhat dot com>
- To: Tom Tromey <tromey at redhat dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Thu, 19 Jul 2012 20:51:34 +0200
- Subject: Re: [PATCH 02/10] clean up allocation of bfd filenames
- References: <87r4s83lu5.fsf@fleche.redhat.com>
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