NAME
          memory_alloc, memory_free, memory_realloc, memory_node -
          cthread memory management

     LIBRARY
          C Threads Library (libcthreads.a)

     SYNOPSIS
          #include <cthread.h>

          RESULT memory_alloc( memory_t *mem_ptr, int size, int node);

          RESULT memory_realloc( memory_t *mem_ptr, int size);

          void memory_free( memory_t mem);

          int memory_node( memory_t mem);



     PARAMETERS
          mem_ptr
                 A pointer to a pointer to memory.

          mem    A pointer to previously allocated memory.

          size   the desired size to be allocated or reallocated

          node   the logical processor upon which the memory should be
                 allocated.

     DESCRIPTION
          These functions comprise Cthread's memory management rou-
          tines.

          memory_alloc() allocates a piece of memory of size <size> on
          logical processor <node> and returns a pointer to this new
          piece of memory in *ptr. On all Cthread implementations, the
          allocated memory is in a shared area available to all pro-
          cessors.  (This may not be the case with malloc().) If the
          underlying memory model is such that the node parameter has
          no reasonable interpretation it is ignored.  The special
          values N_CURRENT and N_ANYWHERE are acceptable values for
          node and require memory to be allocated on the current node
          or on any node, respectively.  See cthread_publish() for a
          possible way of making pointer to the allocated memory
          available to all processors in a static global variable.

          memory_realloc() changes the size of the block referenced by
          *ptr to size bytes.  The value of *ptr will be changed if it
          is necessary to move the block to increase its size.  The
          contents of the block will be unchanged up to the lesser of
          the new and old sizes.  The value of *ptr must be one previ-
          ously returned by memory_alloc() or memory_realloc().

          memory_free() releases a block of memory previously allo-
          cated by memory_alloc() or memory_realloc().

          memory_node() returns the node upon which a block of memory
          resides.  Note that this function is only valid for memory
          returned by memory_alloc() or memory_realloc().
          memory_node() returns -1 if the underlying memory model is
          such that memory is not associated with a particular node.

     DIAGNOSTICS
          memory_alloc() and memory_realloc() return result T_SUCCEED
          if the allocation or reallocation is successful.  They
          return T_TOO_BIG_MEMORY_MODULE if the size requested is to
          large to satisfy with the current value of memory_exponent
          (See cthread_configure(3) and cthread_parse_args(3)).  They
          return T_NOMEMORY if there is currently insufficient memory
          to satisfy the request.

          memory_free() will behave unexpectedly if passed a pointer
          that was not returned by the allocation routines or if a
          free chunk is freed again.

     SEE ALSO
          cthread_intro(3), cthread_publish(3), cthread_configure(3),
          cthread_parse_args(3)

     AUTHOR
          Cthreads was written and maintained by many people.
          This man page written by Greg Eisenhauer.