[gclist] C realloc/free semantics with conservitave GC.

Charles Fiterman cef@geode.geodesic.com
Fri, 31 May 1996 12:44:21 -0500


Consider the following realloc/free semantics.

First realloc calls free on old objects exactly as
described in K&R.

free() examines a switch gcEnableFree which defaults
to zero. If gcEnableFree then it actually does the
free().

If the !gcEnableFree the free()d object is added to
a list. On the next allocation or collection all objects 
on the list are zeroed.

This allows the ugly but official
	for (p = root; p; p = p->next)
		free(p);

It minamizes the problem of old pointers aiming at something
that looks logical.

If a bogus pointer keeps a free()d object alive at least
the problem wont cascade.

It avoids loose pointer bugs associated with respecting free().