





            


                    MMeemmMMggrr ---- AA SSiimmppllee MMeemmoorryy MMaannaaggeemmeenntt LLiibbrraarryy
                                    RReelleeaassee 11..0022


                                    _P_a_u_l _D_u_B_o_i_s
                              _d_u_b_o_i_s_@_p_r_i_m_a_t_e_._w_i_s_c_._e_d_u
                     Wisconsin Regional Primate Research Center
                          Revision date:  25 October 1991


            11..  IInnttrroodduuccttiioonn

            MemMgr is a fairly trivial memory management library.  There
            is little it does that cannot be done using routines in  the
            C library.  (In fact, allocation and disposal is implemented
            using C library routines.)  The purposes of MemMgr are  two-
            fold.

            (i)  Minimize  configuration  burden  on  applications  that
                 dynamically allocate memory.  For instance, malloc() on
                 some  systems  returns  a  char  pointer;  on others it
                 returns a void pointer.  The  MemMgr  library  routines
                 encapsulate  system-specific  configuration differences
                 and exports a fixed interface which is  system-indepen-
                 dent.  Once you compile and install it, you just use it
                 without thinking about whether your UNIX is System V or
                 BSD inspired.

            (ii) Provide  two parallel sets of allocation routines which
                 either return NULL  (for  applications  which  want  to
                 check)  or panic (for applications which simply want to
                 die) on allocation failures.  Panicking is  implemented
                 using the ETM library, which introduces a dependency on
                 the ETM distribution.  So be it.  I use ETM for all  my
                 programs anyway.

            22..  IInnssttaallllaattiioonn

            This  release  of  MemMgr  is configured using imake and the
            standard WRPRC multiple-project configuration files, so  you
            also  need  to  obtain  the WRPRC configuration distribution
            (version 1.03 or higher) if you want to build it  the  usual
            way.   (If  you  want to avoid imake, the Makefile is simple
            enough that you should be able to tweak it by hand.)

            You also need to obtain and install  the  Exception/Termina-
            tion Manager (ETM) library to build this distribution.

            If you are using imake, take a look at the files in the con-
            fig directory and change things if you want.  Then build the
            distribution with ``make World'' or:



            Revision date:  25 October 1991      Printed:  11 June 19125





            Memory Manager Library      - 2 -


                 make Bootstrap
                 make depend
                 make
                 make install


            33..  PPrrooggrraammmmiinngg IInntteerrffaaccee

            Source  files  for applications using MemMgr routines should
            include memmgr.h.

            Applications using MemMgr should  be  linked  with  -lmemmgr
            -letm.

            cchhaarr **AAllllooccNNPP ((ssiizzee))
            iinntt     ssiizzee;;

            Allocate size bytes of memory and return a pointer to it, or
            NULL if insufficient memory is available.  The memory is not
            guaranteed to be zeroed.

            cchhaarr **AAlllloocc ((ssiizzee))
            iinntt     ssiizzee;;

            Like  Alloc(), but panics if insuffient memory is available.

            cchhaarr **SSttrrAAllllooccNNPP ((ss))
            cchhaarr    **ss;;

            Allocates space for the string pointed to by s (including  a
            null  byte  at  the  end),  copies  the  string into it, and
            returns a pointer to the copy.  Returns NULL if s is NULL or
            insufficient memory is available.

            cchhaarr **SSttrrAAlllloocc ((ss))
            cchhaarr    **ss;;

            Like  StrAllocNP(),  but  panics  if s is NULL or insuffient
            memory is available.

            cchhaarr **VVAAllllooccNNPP ((ccoouunntt,, ssiizzee))
            iinntt     ccoouunntt,, ssiizzee;;

            Allocate count objects of size bytes of memory and return  a
            pointer  to it, or NULL if insufficient memory is available.
            The memory is not guaranteed to be zeroed.

            cchhaarr **VVAAlllloocc ((ccoouunntt,, ssiizzee))
            iinntt     ccoouunntt,, ssiizzee;;

            Like VAlloc(), but panics if insuffient memory is available.






            Revision date:  25 October 1991      Printed:  11 June 19125





                                        - 3 -     Memory Manager Library


            cchhaarr **RReeaallllooccNNPP ((pp,, ssiizzee))
            cchhaarr    **pp;;
            iinntt     ssiizzee;;

            Reallocate  the  block  of memory pointed to by p to be size
            bytes long, free p and return a pointer to the new block.  p
            should  have  been allocated by one of the other MemMgr rou-
            tines.  Returns NULL if insufficient memory is available; in
            this  case  the  block  pointed  to by p is nnoott freed.  Also
            returns NULL if p is NULL.

            cchhaarr **RReeaalllloocc ((pp,, ssiizzee))
            cchhaarr    **pp;;
            iinntt     ssiizzee;;

            Like Realloc(), but panics if p is NULL or insuffient memory
            is available.

            vvooiidd FFrreeee ((pp))
            cchhaarr    **pp;;

            Frees the chunk of memory pointed to by p; the memory should
            have been allocated by one of  the  other  MemMgr  routines,
            with the exception that it is safe to pass NULL to Free().

            44..  DDiissttrriibbuuttiioonn aanndd UUppddaattee AAvvaaiillaabbiilliittyy

            The  MemMgr  distribution  may  be  freely circulated and is
            available for anonymous FTP access under the ~ftp/pub direc-
            tory  on host ftp.primate.wisc.edu.  Updates appear there as
            they become available.

            The ETM and WRPRC configuration distributions are  available
            on ftp.primate.wisc.edu as well.

            If  you do not have FTP access, send requests to the address
            software@primate.wisc.edu.  Bug reports, questions,  sugges-
            tions and comments may be sent to this address as well.



















            Revision date:  25 October 1991      Printed:  11 June 19125


