logoalt Hacker News

magicalhippolast Friday at 1:55 PM2 repliesview on HN

But the letter is non-specific. It doesn't clarify if unique refers to unique when compared to non-zero allocations, or unique when called multiple times.

The C99 standard[1] seems to have worded it more precisely:

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.

[1]: https://rgambord.github.io/c99-doc/sections/7/20/3/index.htm...


Replies

f1shyyesterday at 6:13 PM

I think that is the problem. I understood unique as „only one“ which means always returns the same. It is imho not clear enough.

bobmcnamaralast Friday at 11:10 PM

It even replaced unique with "disjoint from any other object".

-1 seems to be disjoint from all objects.

show 1 reply