On Fri, 22 Nov 2002, M. Warner Losh wrote: > In message: <[EMAIL PROTECTED]> > Marc Recht <[EMAIL PROTECTED]> writes: > : A malloc(0) returns always 0x800 on my system. This causes some third-party > : software to fail, because they expect malloc(0) to return NULL. Is this a > : bug or a feature? malloc(3) doesn't mention anything. > > malloc(0) is undefined. If people expect it to return NULL, that > software is not standard conforming.
Er, malloc(0) is defined as returning either a null pointer or a pointer to 0 bytes of allocated space. Which one it chooses to return is implementation-defined, not undefined. C90 has a bogus requirement that the pointer for malloc(0) be "unique", whatever that means. C99 only requires that the objects pointed to by the results of malloc() be disjoint, and this is satisfied by FreeBSD's behaviour of returning the same magic pointer for each instance of malloc(0). Bruce To Unsubscribe: send mail to [EMAIL PROTECTED] with "unsubscribe freebsd-current" in the body of the message