On 23 Sep 2012, at 20:27, Garrett Cooper wrote:

>    +1. free(3) should silently ignore NULL parameters passed into it.

Indeed.  The C standard's description for free() states that:

> If ptr is a null pointer, no action occurs.

This means that a standards-compilant compiler is entirely at liberty to elide 
these checks (not sure if GCC or LLVM does, but both have optimisation passes 
that optimise based on assumptions about standard library functions, although 
they may not run when compiled in a freestanding environment).

The only reasons for a NULL check before free() should be:

- Sanity checking (i.e. this pointer is never meant to be NULL, assert that it 
isnt)
- Recursive cleanup (don't dereference this pointer to clean up its elements if 
it is NULL)

David_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to