[net.lang.c] garbage collection in C

mark@umcp-cs.UUCP (06/03/84)

A footnote on page 11 of the AT&T Bell Labs Memo 109 entitled
Data Abstraction in C, by Bjarne Stroustrup, says that a garbage
collector version of the malloc function exists.  Any one else
ever heard of this?  Know where I can get one?
-- 
Spoken: Mark Weiser 	ARPA:	mark@maryland
CSNet:	mark@umcp-cs 	UUCP:	{seismo,allegra}!umcp-cs!mark

johnl@haddock.UUCP (06/06/84)

#R:umcp-cs:-733100:haddock:12400008:000:734
haddock!johnl    Jun  5 14:10:00 1984

I made a garbage collected version of malloc() a while ago for a little
Lisp interpreter I was playing with (no, I didn't malloc atoms and cons
cells, but I did malloc strings and on a Z8000, you need to reclaim all
the space you can get.)

The standard version of malloc() keeps a link list of all of the
storage chunks in the arena.  The low order bit of each link word
is the busy flag.  So to garbage collect, you merely run through
the arena, clearing all of the busy bits, and then walk through
your useful data structures, setting the busy bits (and you can use
the same busy bits to avoid infinite recursion with circular lists.)
Shazam -- you're done, and malloc will cheerfully reuse the free space.

John Levine, ima!johnl