malloc(0) returns a pointer, not NULL
malloc(0) returns a pointer, not NULL
- Subject: malloc(0) returns a pointer, not NULL
- From: Michael David Crawford <email@hidden>
- Date: Tue, 05 May 2015 14:19:52 -0700
This came as news to me.
The C spec says this is implementation-definited; malloc(0 may return
either NULL or it may return a pointer that can subsequently be passed
to free().
In the case of the bug I'm looking at just now, it's an error in my
code, so I now have:
assert( 0 != bytes );
ptr = malloc( bytes );
Just thought you'd like to know,
Mike
Michael David Crawford, Consulting Software Engineer
email@hidden
http://www.warplife.com/mdc/
Available for Software Development in the Portland, Oregon Metropolitan
Area.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden