logoalt Hacker News

masfuertelast Thursday at 5:55 PM1 replyview on HN

It's POSIX.

> Each [...] allocation shall yield a pointer to an object disjoint from any other object. The pointer returned points to the start (lowest byte address) of the allocated space. If the space cannot be allocated, a null pointer shall be returned. If the size of the space requested is 0, the behavior is implementation-defined: either a null pointer shall be returned, or the behavior shall be as if the size were some non-zero value, except that the behavior is undefined if the returned pointer is used to access an object.

https://pubs.opengroup.org/onlinepubs/9799919799/functions/m...


Replies

MaxBarracloughlast Thursday at 6:40 PM

Not just POSIX, also the ISO C standard itself. https://en.cppreference.com/w/c/memory/malloc

show 2 replies