This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 02/10] clean up allocation of bfd filenames


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]