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

bugzilla-daemon at rtems.org bugzilla-daemon at rtems.org
Tue Jan 25 12:50:11 UTC 2011


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

--- Comment #5 from Ralf Corsepius <ralf.corsepius at rtems.org> 2011-01-25 06:50:10 CST ---
(In reply to comment #4)
> The non-NULL return is more common.

I regret, but you leave me no other choice but to become more explicit.

a) malloc(0) is non-portable code and needs special treatment on the caller
side. I.e. It's unsafe and nonportable (== broken code) to call malloc(size) if
size can be < 1. 



b) your sentence above is wrong.

malloc(0) returning 0 is the tradional unix behavior and is much older than
Linux and POSIX. May be it's thanks to your age and due to your lack of
experience with other OSes but Linux, you're not aware about this.

> RTEMS needs a special case to force the
> NULL return of malloc(0). 
So what? What is the problem you are trying to resolve?

> A _Workspace_Allocate(0) will return non-NULL for
> example.
So what? Implementation detail.

>  The C standard declares two valid implementation behaviors.  I don't
> see why RTEMS should choose one that is less common and in addition to that
> needs a special case to enforce it.

Pardon ... cf. above.

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