Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!columbia!cubmol!ping
From: ping@cubmol.BIO.COLUMBIA.EDU (Shiping Zhang)
Newsgroups: comp.lang.c
Subject: effect of free()
Message-ID: <319@cubmol.BIO.COLUMBIA.EDU>
Date: 13 Aug 89 22:02:25 GMT
Reply-To: ping@cubmol.UUCP (Shiping Zhang)
Organization: Dept. of Biology, Columbia Univ., New York, NY
Lines: 26


When some space is allocated using calloc() or similar routines
and assigned to more than one point, for example as in following lines,

int *pt1,*pt2;

pt1=(int *)calloc(100,sizeof(int);
pt2=pt1;

then if free() is called using ONE of the points, say pt1, as its 
argument, is the space pointed by pt1 really freed? Actually I have
two questions about this problem above.
First, can pt2 still be used as a valid point? In other words,
is pt2 still pointing to the location it is assigned to? 
My answer to this question SEEMS yes according to some tests I made.
Second, would the space still pointed to by pt2 be reallocated
by other calls to calloc() or other similar funtions?
According to the document I read about free(), the space pointed
by the argument to free() is made available for further allocation,
though its contents are left unchanged. But it does not say what will
happen to the other points pointed to the same space.

Can anyone clarify this issue for me? Thanks.


-ping