GALLOC(3) GALLOC(3) NAME galloc, gfree, garbage - storage allocation with garbage collection SYNOPSIS char *galloc(n) unsigned n; gfree(p) char *p; garbage( ) DESCRIPTION These functions perform heap storage allocation with garbage collection. Galloc allocates a block of at least n bytes and returns a pointer to it. Gfree frees a block previously allocated by galloc. When space gets tight, garbage blocks are freed automati- cally. A block allocated by galloc is deemed to be garbage unless it is reachable. A reachable block is one whose first byte is pointed to by a declared C variable or by a pointer in a reachable block. The frequency of garbage collection is controlled by exter- nal variables declared long gcmax = 5000, gcmin = 50; No more than gcmax allocations may intervene between auto- matic collections; this feature will help contain the growth of virtual address space. At least gcmin allocations must intervene, otherwise garbage collection will be abandoned as fruitless. Garbage may be called to do garbage collection at an arbitrary time. Malloc(3) and galloc allocate from the same arena, but gar- bage collection affects only galloc blocks. Free (see malloc(3)) must not be used on blocks allocated with galloc. DIAGNOSTICS Galloc returns a null (0) pointer when space cannot be found. SEE ALSO malloc(3) GALLOC(3) GALLOC(3) BUGS Garbage collection is conservative; blocks that appear to be pointed to from within declared storage will not be freed, regardless of whether the apparent `pointers' were declared as such.