What does malloc(0) return?

Doug Gwyn gwyn at smoke.brl.mil
Sat Jun 1 05:17:48 AEST 1991


In article <11614 at ncar.ucar.edu> steve at unidata.ucar.edu (Steve Emmerson) writes:
>The subject-line says it all and my K&R2 is silent on the matter.

malloc(0) should return either NULL or a pointer to some storage location.
Technically the behavior is undefined, since there are no objects of the
specified size (0) according to the standard.



More information about the Comp.std.c mailing list