[BusyBox] Re: ash devel revision 1.68

Glenn McGrath bug1 at optushome.com.au
Tue Jan 14 14:27:03 UTC 2003


On Tue, 14 Jan 2003 11:08:30 -0700
Erik Andersen <andersen at codepoet.org> wrote:

> I don't understand.  I was debugging busybox with dmalloc
> enabled.  It mentioned that this line was calling free(0), which
> is not an error, but is messy.  So I changed it.  I don't know
> what aaronl did in august 2002.  Did he made a similar change?

I think free(0) its a very sensitive subject amounst C programmers.

The author of dmalloc considers it a bug in glibc for it to free null,
and bad programming practice to willingly do it, thats why it generates
a warning, a default upstream build of dmalloc will cause a fatal error
rather than just a warning.

I think the basis of their argument is that pointers are difficult and
dangerous so people should take special care when handling them.

Adding an if statement adds 9 bytes to the binary, not much, but the
only benefit we get from this condition is that it prevents messy
warning in the dmalloc log ;)

If we were to put conditions around free() more than twice (i only
checked with a static function, not extern) then it would be worth
having a general xfree() function that procides this condition.

But again this would serve us no practical benefit as it reproduces
functionality in glibc.

I vote for no if(ptr) free(ptr), just free(ptr)

A compromise would be to have a macro for xfree that adds the condition
if dmalloc is being used and removes it for proper builds.



Glenn
 



More information about the busybox mailing list