malloc(0)
H.J. Lu
hjl@lucon.org
Mon Jun 1 07:22:00 GMT 1998
>
>
> There's been some discussion recently in comp.std.c about what
> malloc(0) and realloc(x, 0) are supposed to do. The standard allows
> returning some non-null pointer in both cases, which is what we
> currently do. However, that non-null pointer has peculiar
> characteristics and it seems to me that it would be less surprising if
> both these operations returned NULL.
>
We used to have it return 0. But we changed it to return 1. I don't
remember what finally convinced us to do so. If the current scheme
is ANSI C compliant, don't change it.
H.J.
More information about the Libc-hacker
mailing list