effect of free()

Shiping Zhang ping at cubmol.BIO.COLUMBIA.EDU
Tue Aug 15 04:01:56 AEST 1989


After I posted the question, I got many responces from both the network
and e-mail. They certainly answered my original questions and clarified
a lot of confusions I had. I am very grateful to all of them.

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. (Same to
the other points point to the same space.)  But I work on a Sun3
machine under unix system, there are more than one process running
at the same time. So will other processes take that space and change
its contents? The answer must be yes to my understanding. Please
confirm me.  Even if no (mc)alloc()'s are called after free() in a
process, how about calls to other functions with local varibles?
The memory spaces for local varibles of functions are fixed at the
begining of a process or allocated dynamically by the parent process
or by the operating system? If the space for local varibles are
allocated dynamically, will the space freed by free() be allocated
for local varibles?


-ping



More information about the Comp.lang.c mailing list