glenda.party
term% ls -F
term% cat index.txt
GALLOC(3)                  Library Functions Manual                  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 collec‐
       tion.

       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 automatically.  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 external variables
       declared

              long gcmax = 5000, gcmin = 50;

       No  more than gcmax allocations may intervene between automatic collec‐
       tions; 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 garbage collec‐
       tion 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)

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.



                                                                     GALLOC(3)