effect of free()

Doug Gwyn gwyn at smoke.BRL.MIL
Sat Sep 9 10:51:10 AEST 1989


In article <247 at bbxeng.UUCP> scott at bbxeng.UUCP (Scott-Engineering) writes:
>In other words - you cannot even *test* a pointer unless you are *sure*
>there is a valid address in it.  I don't think so.

There is no way a strictly conforming C program can create an invalid
pointer value, apart from free()ing a valid one that it got from malloc()
or realloc().  The moment an improper pointer value is created via
arithmetic operations, the program has violated the guarantees of the
Standard, and the implementation would be free to trap immediately.

>Is NULL some kind of special exception?

Yes, as has been mentioned many times previously, null pointers (and null
pointer constants, not the same thing!) are special critters with their
own unique rules.



More information about the Comp.lang.c mailing list