This is the mail archive of the binutils@sourceware.org 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]
Other format: [Raw text]

Re: question about memory allocate and free


Hi Ligang,

1. In Binutils source, the memory allcating functions are xmalloc() and
obstack_begin().
but, a lot of allocated memory are not set free by free() or
obstack_free(). why?

Bugs (mostly). Some times it is too difficult to know when it is safe to free the memory, but most of the time any failure to free allocated memory is a bug.


Dose it result in memory leak?

Yes. Although probably not for very long. ie the memory is mostly likely needed right up until the BFD library has finished its work, at which point it is presumed that the client using the library will have finished its work as well, and so it will be terminating.


2. In added files for porting Binutils, need i release allocated memeoy and
which
function should i use?

bfd_alloc() and bfd_free() or their related functions. These are all defined in bfd/opncls.c.


Cheers
  Nick




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