[Bug 1730] Change malloc(0) behavior to match FreeBSD and Linux

bugzilla-daemon at rtems.org bugzilla-daemon at rtems.org
Tue Jan 25 14:27:12 UTC 2011


https://www.rtems.org/bugzilla/show_bug.cgi?id=1730

--- Comment #9 from dufault at hda.com 2011-01-25 08:27:11 CST ---
"If the code depends on the malloc(0) behavior it is not robust code from my
point of view."

My point is simple: If malloc() returns non-zero you get back something that
can be passed to free() or realloc(), and the behavior will be identical as
passing a zero.  It's only other use is to trash the heap.

If malloc() returns zero you can trap illegal references to it.   I can make
the same statement I'm quoting above: If the code depends on the malloc(0)
behavior it is not robust code.  That existing code you discuss that is harder
to use is suspect.

Anyway, I much prefer that malloc(0) return 0.  I hope we both understand the
other's point of view.  'Nuff said.

-- 
Configure bugmail: https://www.rtems.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are watching all bug changes.



More information about the bugs mailing list