effect of free()

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Sep 9 11:05:01 AEST 1989


In article <10817 at riks.csl.sony.co.jp> diamond at riks. (Norman Diamond) writes:
>Well, because a freed pointer is still valid in a call to realloc
>(as long as there are no intervening *alloc calls), ...

Nope.  That guarantee that you've read in some MALLOC(3) UNIX manual
page, was documenting an arguably useful feature of a particular
implementation.  There have been malloc/free/realloc implementations
for many years that had no such guarantee, and X3J11 were not convinced
that there was sufficient need for such a guarantee to justify the
heavy implementation constraints imposed by it.  Therefore the Standard
makes realloc(free(ptr),size) explicitly undefined behavior.



More information about the Comp.lang.c mailing list