effect of free()

Blair P. Houghton bph at buengc.BU.EDU
Wed Aug 16 02:33:21 AEST 1989


In article <320 at cubmol.BIO.COLUMBIA.EDU> ping at cubmol.UUCP (Shiping Zhang) writes:
>
>Now some new questions arises. Many people said that after free()
>is called, the point used as the argument to free() is still valid
>and can be used IF NO (mc)alloc()'s are called after the call to free().
>I understand the reason to say that is because that point still points
>to the same space and the contents of it is not disturbed.

Well, as many have informed me after I posted a response to the original,
some implementations are not all implementations.

It is possible that the call to free() may write into the freed block, and
that the OS may gain control of it, and use it for whatever the
system uses memory for.

I guess the word is, once space is freed, don't even try to get data
out of it.  It's risky at least, and nonportable without question.

				--Blair
				  "Four more compilers and
				   daddy's got a new pair of
				   shoes."



More information about the Comp.lang.c mailing list