effect of free()

Clifford C. Skolnick cliffs at suntrek.east.sun.com
Tue Aug 15 00:25:16 AEST 1989


In article <3756 at buengc.BU.EDU> bph at buengc.BU.EDU (Blair P. Houghton) writes:

   >then if free() is called using ONE of the points, say pt1, as its 
   >argument, is the space pointed by pt1 really freed?

   Yes.  It can now be allocated to something else.  It is _not_,
   however, cleared or otherwise overwritten by free(), nor are
   any pointers into it deallocated or overwritten.

In current implimentations this is true.  But what if some person makes
a C library that actually returns the space to the operating system?  I
would change this to a no.

   >[questions about using the pointer]
   >My answer to this question SEEMS yes according to some tests I made.

   No intervening [mc]alloc()'s, no problem.  You have only your
   conscience to maintain.

Again, what if the memory was returned to the operating system?

			Cliff Skolnick

--
Cliff Skolnick			cliffs at sunrock.east.sun.com



More information about the Comp.lang.c mailing list