effect of free()

Karl Heuer karl at haddock.ima.isc.com
Wed Aug 16 09:59:53 AEST 1989


In article <3777 at buengc.BU.EDU> bph at buengc.bu.edu (Blair P. Houghton) writes:
>I guess the word is, once space is freed, don't even try to get data
>out of it.

It's worse than that.  Once space is free()'d, don't even copy the obsolete
pointer value from one pointer object to another.  If the segment has been
released, loading its value into an address register could cause a trap.

On the other side, it really was legal (and even encouraged) at one time to do
certain things after calling free().  This has generally been recognized as a
mistake, though I suspect the offending man pages still exist.

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list