In message <[EMAIL PROTECTED]>
Gibbs Tanton - tgibbs <[EMAIL PROTECTED]> wrote:
> No, the behavior of malloc(0) is implementation defined.
It is, yes, but there are only two legal results according to
the ISO C standard:
"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.
In other words it can't crash or do anything else undesirable, and
the result will always be something that can't be dereferenced, but
can be freed (given that the standard requires free(NULL) to work).
Given that, although we can't say the behaviour is strictly speaking
consistent it is true that as far as performing normal operations on
the pointer go you are unlikely to notice which behaviour a given
platform has chosen.
Tom
--
Tom Hughes ([EMAIL PROTECTED])
http://www.compton.nu/