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

bugzilla-daemon at rtems.org bugzilla-daemon at rtems.org
Tue Jan 25 13:20:43 UTC 2011


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

dufault at hda.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |dufault at hda.com

--- Comment #7 from dufault at hda.com 2011-01-25 07:20:42 CST ---
"It is useless to discuss if implementation A or B is better or whatever. 
RTEMS should implement the most common one.  This is my point."

IMHO RTEMS should implement the one most likely to lead to robust code.  On
some platforms we can trap NULL dereferences.  I'm not too concerned with a
minor conditional branch in malloc() - malloc() is always going to be
heavy-weight due to the nature of the beast.

Can you point to some code I can reference so I can understand the advantage of
returning a non-NULL non-dereferencable pointer from malloc()?  The only case I
can make up is code that allocates a pool of pointers, and tests the returned
pointer for NULL when it's allocated (thus breaking portability), but carefully
never uses that non-NULL pointer in a way that it is isn't dereferenced.  That
is dangerous code I want to examine anyway since even if it works today it's
likely to become broken and trash the heap tomorrow.

I'm interested to see additional beneficial cases I can't think of.

-- 
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