* question about memory allocate and free
@ 2006-03-06 6:20 ligang
2006-03-07 8:24 ` Nick Clifton
0 siblings, 1 reply; 2+ messages in thread
From: ligang @ 2006-03-06 6:20 UTC (permalink / raw)
To: binutils
hi,
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? Dose it result
in memory leak?
2. In added files for porting Binutils, need i release allocated memeoy and
which
function should i use?
Best regards
Ligang
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: question about memory allocate and free
2006-03-06 6:20 question about memory allocate and free ligang
@ 2006-03-07 8:24 ` Nick Clifton
0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2006-03-07 8:24 UTC (permalink / raw)
To: ligang; +Cc: binutils
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-03-07 8:24 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-06 6:20 question about memory allocate and free ligang
2006-03-07 8:24 ` Nick Clifton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).