whgc  whgc

whgc - WanderingHorse.net Garbage Collector library for C

Welcome to the whgc source code repository! This repository hosts small collection of Ccode to assist in freeing up memory in C programs (i.e. garbage collection or GC).

It provides these different approaches to GC:

  • "Basic" GC: client code registers to-clean-up objects with a "GC context", along with a pointer to a finalization function. When the context is cleaned up, all registered objects are destroyed in the reverse order of their registratino. It is also possible to search for objects in the GC pool, so this API can be used as a "self-cleaning hashtable".
  • Clients register objects, as above, and increment/decrement a reference count as they add/remove references to it. When the RC goes to 0, the object is destroyed.
  • A GC context specialized for shared string instances. Intended for apps which may have many copies of the same dynamically-allocated strings, this API provides reference-counting features to the strings, to try to keep only a single copy in memory.

Code Status: Works for me! i use the basic GC API intensively in pegc and am quite satisfied with it. The other implementations have seen less usage/testing.

Author: Stephan Beal (http://wanderinghorse.net/home/stephan)

License: the core library is Public Domain, but some of the borrowed utility code is released under a BSD license (see whhash.{c,h} for details).

Downloading: See the downloads page.