malloc(0)

Doug Gwyn gwyn at smoke.BRL.MIL
Tue Aug 7 22:23:09 AEST 1990


In article <1990Aug6.142050.18629 at gli.com> bobj at gli.com (Robert Jacobs) writes:
>About using malloc(0) to point to a unique place. What's wrong with using
>malloc(1) ??
>That way malloc(0) would do what is expected. Return a NULL pointer.
>This just seems too easy, doesn't it?

Yes, it seems too easy because it is too easy.

The issue was that it is not clear what to "expect" malloc(0) to return.
The standard was deliberately vague on this point, because X3J11 was
fairly evenly divided on the issue, but in much better agreement that it
wasn't such an important point that it had to be nailed down in the spec.



More information about the Comp.std.c mailing list