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

bugzilla-daemon at rtems.org bugzilla-daemon at rtems.org
Fri Jan 21 08:05:38 UTC 2011


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

           Summary: Change malloc(0) behavior to match FreeBSD and Linux
           Product: RTEMS
           Version: HEAD
          Platform: All
        OS/Version: RTEMS
            Status: NEW
          Severity: normal
          Priority: P3
         Component: cpukit
        AssignedTo: joel.sherrill at oarcorp.com
        ReportedBy: sebastian.huber at embedded-brains.de


Created an attachment (id=1098)
 --> (https://www.rtems.org/bugzilla/attachment.cgi?id=1098)
Patch.

>From C99 we have (section 7.20.3): If the size of the space requested is zero,
the behavior is implementation- defined: either a null pointer is returned, or
the behavior is as if the size were some nonzero value, except that the
returned pointer shall not be used to access an object.

RTEMS currently returns NULL for malloc(0) due to some special case handling in
malloc().  FreeBSD and Linux on the other hand return a non-NULL pointer in
most cases.  To ease the porting of applications we should adopt this approach
and remove the special case in malloc() and delegate the allocation of a zero
size to the heap implementation.  The current heap implementation returns a
non-NULL pointer in this case unless the heap is completely used.

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