This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


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

Re: Retreiving dynamic links through BFD


   Date: Wed, 26 May 1999 22:12:59 -0700
   From: Jeff Bailey <jbailey@nisa.net>

   struct bfd_shared_libs {
	   char *libname;
   };

   boolean bfd_fetch_shared_libs (bfd *, int *, struct bfd_shared_libs *);

Looks reasonable to me.  I might use a linked list rather than an
array.

   Is it okay to malloc() in bfd, knowing that the result will never be 
   freed, or should I somehow expect the calling function to pre-malloc the 
   space for me?

Never freeing the space doesn't sound good.  There are two approaches
used in BFD.  The BFD functions which return relocs and symbol tables
work by using two functions: one to get the size required, and the
other to fill in the allocated buffer.  bfd_elf_get_bfd_needed_list
uses bfd_alloc, which means that the caller does not have to worry
about freeing the buffer.

Probably using bfd_alloc is all right for this case.  Memory allocated
using bfd_alloc is freed when the BFD is closed.

   Is it safe to assume GNU realloc is being used (or something else that 
   doesn't trash the contents of the array)?

You avoid this problem by creating a linked list.  It is not safe to
assume that GNU realloc is being used, but I'm not sure why it
matters.

   Will you need paperwork from me for this patch when written?

Yes.

Ian

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