vext01/libdefile — comment on commit 1ffde1bb0c708374079a6e9b22252c93e5b39167
File:  line 0
By vext01:

On Tue, Oct 25, 2011 at 10:43:06AM -0700, Christiano F. Haesbaert wrote:
> Why heap alloc this ?

How would you do it? I am trying to avoid the case where the fields can
be either statically/dynamically allocated. Because, if you wanted to
free this, how would you know if it was stack (or global) or heap allocated and thus if you should free the buffer?

> You also have a memory leak if the user specified -f.

The reference to the buffer is never lost and memory consumption does
not continually increase. Some would say this is not a leak.

But strictly speaking, the buffer is not freed, you are right. But
then *nothing* is freed when you exit due to errors either.

I am not sure what the correct thing to do is. In my other project I
never used err/errx, and just returned an error state which eventually
frees *everything* that was ever heap allocated. However, I rarely see
this in bsd code.

Thoughts?

--
Best Regards
Edd Barrett

http://www.theunixzoo.co.uk