::::::::::::::
Changes-1.01
::::::::::::::
Changes to MemMgr distribution for release 1.01.


Fixed bug in ReallocNP() - it was freeing memory it shouldn't have been.
::::::::::::::
Changes-1.02
::::::::::::::
Changes to MemMgr distribution for release 1.02.


Added Valloc() and VAllocNP() for allocating vectors of objects.
::::::::::::::
Changes-1.03
::::::::::::::
Changes to MemMgr distribution for release 1.03.

Now configured with WRPRC2 imake configuration files.


Most important code change:
All functions are #define'd as "# define f f_" in memmgr.h.  This
causes failure at link time if memmgr.h wasn't included everywhere
it should have been.  This can help a lot on compilers such as THINK C.
It means, however, that libraries that use MemMgr should be recompiled
and reinstalled, or programs using those libraries will get "undefined
symbol" errors for MemMgr function names.

memmgr.h now idempotent; may be included more than once safely.
::::::::::::::
Imakefile
::::::::::::::
XCOMM Memory Allocation Library Imakefile

XCOMM Use "make World" to build the distribution.  But before you do that,
XCOMM look at the files in the config subdirectory to see if you want
XCOMM to change anything.

XCOMM Requires the WRPRC2 imake configuration files.


SRCS = \
	alloc.c \
	allocnp.c \
	stralloc.c \
	strallocnp.c \
	realloc.c \
	reallocnp.c \
	valloc.c \
	vallocnp.c \
	free.c

OBJS = \
	alloc.o \
	allocnp.o \
	stralloc.o \
	strallocnp.o \
	realloc.o \
	reallocnp.o \
	valloc.o \
	vallocnp.o \
	free.o

NormalLibraryObjectRule()

BuildNormalLibrary(memmgr,$(SRCS),$(OBJS))
InstallLibrary(memmgr,$(LOCALUSRLIBDIR))

BuildLintLibrary(memmgr,$(SRCS))
InstallLintLibrary(memmgr,$(LOCALLINTLIBDIR))

InstallIncludeFile (memmgr.h,$(LOCALINCLUDEROOT))

DependTarget()

SimpleWorldTarget($(PROJECTNAME),$(PROJECTRELEASE))

XCOMM documentation

TroffMsToPostScript(memmgr.ps,memmgr.ms,NullArg,NullArg)
::::::::::::::
Makefile
::::::::::::::
# Makefile generated by imake - do not edit!
# $XConsortium: imake.c,v 1.51 89/12/12 12:37:30 jim Exp $
#
# The cpp used on this machine replaces all newlines and multiple tabs and
# spaces in a macro expansion with a single space.  Imake tries to compensate
# for this, but is not always successful.
#

# -------------------------------------------------------------------------
# Makefile generated from "Imake.tmpl" and <Imakefile>.
#
# Platform-specific parameters may be set in the appropriate .cf and
# .p-cf configuration files.  Site-wide parameters may be set in the
# files site.def and site.p-def.  Full rebuilds are recommended if
# any parameters are changed.

# -------------------------------------------------------------------------
# site-specific configuration parameters that need to come before the
# platform-specific parameters - edit site.def or site.p-def to change

# site:  Primate Center 89/12/22

# -------------------------------------------------------------------------
# platform-specific configuration parameters specific to this project
# edit sun.p-cf to change

# -------------------------------------------------------------------------
# platform-specific configuration parameters
# edit sun.cf to change

# platform:  sun.cf	93/06/30
# operating system:  SunOS 4.1.1

# -------------------------------------------------------------------------
# site-specific configuration parameters that go after the
# platform-specific parameters - edit site.def or site.p-def to change

# site:  Primate Center 89/12/22

# -------------------------------------------------------------------------
# project-specific system and project description parameters
# Edit Imake.p-params to change

# -------------------------------------------------------------------------
# Standard system and project description parameters
# Edit Imake.params to change

# -------------------------------------------------------------------------
# definitions common to all Makefiles

          PATHSEP = /

            SHELL = /bin/sh

  VARARGS_DEFINES = -DVARARGS

              TOP = .
      CURRENT_DIR = .

# Configuration file identification - name and release level

         CONFIGNAME = WRPRC2
 CONFIGMAJORRELEASE = 2
 CONFIGMINORRELEASE = 04
      CONFIGRELEASE = $(CONFIGMAJORRELEASE).$(CONFIGMINORRELEASE)
      CONFIGROOTDIR = $(USRLIBDIR)/config

# Project identfication - name and release level

        PROJECTNAME = Memory Management Library
PROJECTMAJORRELEASE = 1
PROJECTMINORRELEASE = 03
     PROJECTRELEASE = $(PROJECTMAJORRELEASE).$(PROJECTMINORRELEASE)

           BINDIR = /usr/local
        USRLIBDIR = /usr/lib
       LINTLIBDIR = $(USRLIBDIR)/lint

           ETCDIR = /usr/etc
      INCLUDEROOT = /usr/include
           TMPDIR = /tmp

     LOCALROOTDIR = /usr/local
      LOCALBINDIR = /usr/local
   LOCALUSRLIBDIR = $(LOCALROOTDIR)/lib
  LOCALLINTLIBDIR = $(LOCALUSRLIBDIR)/lint
      LOCALADMDIR = $(LOCALROOTDIR)/adm
      LOCALETCDIR = $(LOCALROOTDIR)/etc
 LOCALINCLUDEROOT = $(LOCALROOTDIR)/include

          MANROOT = /usr/man
    MANSOURCEPATH = $(MANROOT)/man
       MAN1SUFFIX = 1
       MAN2SUFFIX = 2
       MAN3SUFFIX = 3
       MAN4SUFFIX = 4
       MAN5SUFFIX = 5
       MAN6SUFFIX = 6
       MAN7SUFFIX = 7
       MAN8SUFFIX = 8
       MANLSUFFIX = l
       MANNSUFFIX = n
        MANSUFFIX = $(MANLSUFFIX)
          MAN1DIR = $(MANSOURCEPATH)$(MAN1SUFFIX)
          MAN2DIR = $(MANSOURCEPATH)$(MAN2SUFFIX)
          MAN3DIR = $(MANSOURCEPATH)$(MAN3SUFFIX)
          MAN4DIR = $(MANSOURCEPATH)$(MAN4SUFFIX)
          MAN5DIR = $(MANSOURCEPATH)$(MAN5SUFFIX)
          MAN6DIR = $(MANSOURCEPATH)$(MAN6SUFFIX)
          MAN7DIR = $(MANSOURCEPATH)$(MAN7SUFFIX)
          MAN8DIR = $(MANSOURCEPATH)$(MAN8SUFFIX)
          MANLDIR = $(MANSOURCEPATH)$(MANLSUFFIX)
          MANNDIR = $(MANSOURCEPATH)$(MANNSUFFIX)
           MANDIR = $(MANSOURCEPATH)$(MANSUFFIX)

           IMBOOT = imboot
           DEPEND = makedepend
             MSUB = msub
        MKDIRHIER = mkdirhier

               AR = ar clq
               CC = cc
              CPP = /lib/cpp $(STD_CPP_DEFINES)
               LD = ld
             LINT = lint
      LINTLIBFLAG = -C
         LINTOPTS = -axz
         LINTLIBS =
               LN = ln -s
             MAKE = make
               MV = mv
               CP = cp
              CMP = cmp

           RANLIB = ranlib
  RANLIBINSTFLAGS =

               RM = rm -f
             TAGS = ctags
             PERL = perl
         PERLPATH = $(LOCALBINDIR)/perl

# Important local programs

              FIGEN = figen
             DISTAR = distar

# Standard system include file directories, defines, etc.

  STD_CPP_DEFINES =

     STD_INCLUDES = -I$(LOCALINCLUDEROOT)
      STD_DEFINES =
       STD_LDLIBS =
      STD_LDFLAGS = -L$(LOCALUSRLIBDIR)

# Project-specific include file directories, defines, etc.

 PROJECT_INCLUDES =
  PROJECT_DEFINES =
   PROJECT_LDLIBS =
  PROJECT_LDFLAGS =

  LOADERLIBPREFIX =
      CDEBUGFLAGS = -O
        CCOPTIONS =

      ALLINCLUDES = $(INCLUDES) $(PROJECT_INCLUDES) $(STD_INCLUDES)
       ALLDEFINES = $(STD_DEFINES) $(PROJECT_DEFINES) $(DEFINES)
           CFLAGS = $(CDEBUGFLAGS) $(CCOPTIONS) $(ALLINCLUDES) $(ALLDEFINES)
        LINTFLAGS = $(LINTOPTS) -DLINT $(ALLINCLUDES) $(ALLDEFINES)
     EXTRA_LDLIBS = $(STD_LDLIBS) $(PROJECT_LDLIBS) $(LDLIBS)
           LDOPTS = $(CDEBUGFLAGS) $(CCOPTIONS) \
			$(LDFLAGS) $(PROJECT_LDFLAGS) $(STD_LDFLAGS)

           RM_CMD = $(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *.a .emacs_* tags TAGS make.log MakeOut

          INSTALL = install
        INSTSTRIP = -s
        INSTOWNER =
        INSTGROUP =
     INSTPROGMODE = -m 0755
  INSTUIDPROGMODE = -m 04755
  INSTGIDPROGMODE = -m 02755
 INSTUGIDPROGMODE = -m 06755
   INSTSCRIPTMODE = -m 0755
      INSTLIBMODE = -m 0644
      INSTDATMODE = -m 0444
      INSTMANMODE = -m 0444
      INSTINCMODE = -m 0444
    INSTPROGFLAGS = $(INSTOWNER) $(INSTGROUP) $(INSTPROGMODE) $(INSTSTRIP)
 INSTUIDPROGFLAGS = $(INSTOWNER) $(INSTGROUP) $(INSTUIDPROGMODE) $(INSTSTRIP)
 INSTGIDPROGFLAGS = $(INSTOWNER) $(INSTGROUP) $(INSTGIDPROGMODE) $(INSTSTRIP)
INSTUGIDPROGFLAGS = $(INSTOWNER) $(INSTGROUP) $(INSTUGIDPROGMODE) $(INSTSTRIP)
  INSTSCRIPTFLAGS = $(INSTOWNER) $(INSTGROUP) $(INSTSCRIPTMODE)
     INSTLIBFLAGS = $(INSTOWNER) $(INSTGROUP) $(INSTLIBMODE)
     INSTDATFLAGS = $(INSTOWNER) $(INSTGROUP) $(INSTDATMODE)
     INSTMANFLAGS = $(INSTOWNER) $(INSTGROUP) $(INSTMANMODE)
     INSTINCFLAGS = $(INSTOWNER) $(INSTGROUP) $(INSTINCMODE)

           SOELIM = soelim
            TROFF = groff
            NROFF = nroff
              TBL = gtbl
              EQN = geqn
             NEQN = neqn
              PIC = pic
        MANMACROS = -man
         MEMACROS = -me
         MMMACROS = -mm
         MSMACROS = -ms

# Library link and dependency specifiers

      BIBSTUFFLIB = -lbibstuff
   DEPBIBSTUFFLIB =
           ETMLIB = -letm
        DEPETMLIB =
           FPLLIB = -lfpl
        DEPFPLLIB =
           FQLLIB = -lfql
        DEPFQLLIB =
         GECOSLIB = -lgecos
      DEPGECOSLIB =
        LOGMGRLIB = -llogmgr
     DEPLOGMGRLIB =
        MEMMGRLIB = $(LOADERLIBPREFIX)$(TOP)/libmemmgr.a
     DEPMEMMGRLIB = $(TOP)/libmemmgr.a
           NDSLIB = -lnds
        DEPNDSLIB =
           NIOLIB = -lnio
        DEPNIOLIB =
         ORDERLIB = -lorder
      DEPORDERLIB =
        SEQNUMLIB = -lseqnum
     DEPSEQNUMLIB =
        SIMSCRLIB = -lsimscr
     DEPSIMSCRLIB =
            TSLIB = -ltokenscan
         DEPTSLIB =

# Makefile-generating commands and parameters

   IMBOOT_DEFINES =
       IMBOOT_CMD = $(IMBOOT) -C $(CONFIGNAME) $(IMBOOT_DEFINES)

# -------------------------------------------------------------------------
# Project-specific imake rules
# Edit Imake.p-rules to change

# -------------------------------------------------------------------------
# Standard imake rules
# Edit Imake.rules to change

# -------------------------------------------------------------------------
# start of Imakefile

# Memory Allocation Library Imakefile

# Use "make World" to build the distribution.  But before you do that,
# look at the files in the config subdirectory to see if you want
# to change anything.

# Requires the WRPRC2 imake configuration files.

SRCS = \
	alloc.c \
	allocnp.c \
	stralloc.c \
	strallocnp.c \
	realloc.c \
	reallocnp.c \
	valloc.c \
	vallocnp.c \
	free.c

OBJS = \
	alloc.o \
	allocnp.o \
	stralloc.o \
	strallocnp.o \
	realloc.o \
	reallocnp.o \
	valloc.o \
	vallocnp.o \
	free.o

.c.o:
	$(RM) $@
	$(CC) -c $(CFLAGS) $*.c

all:: libmemmgr.a
libmemmgr.a: $(OBJS)
	$(RM) $@
	$(AR) $@ $(OBJS)
	$(RANLIB) $@

clean::
	$(RM) libmemmgr.a

lint:: lint.libmemmgr.a
lint.libmemmgr.a:
	$(LINT) $(LINTFLAGS) $(SRCS) $(LINTLIBS)

install:: i.libmemmgr.a
i.libmemmgr.a:: libmemmgr.a
	@if [ -d $(LOCALUSRLIBDIR) ]; then set +x; \
	else (set -x; $(MKDIRHIER) $(LOCALUSRLIBDIR)); fi
	$(INSTALL) -c $(INSTLIBFLAGS) libmemmgr.a $(LOCALUSRLIBDIR)/libmemmgr.a
	$(RANLIB) $(LOCALUSRLIBDIR)/libmemmgr.a

lintlib:: llib-lmemmgr.ln

llib-lmemmgr.ln:: $(SRCS)
	$(RM) $@
	$(LINT) $(LINTLIBFLAG)memmgr $(LINTFLAGS) $(SRCS)

clean::
	$(RM) llib-lmemmgr.ln

install.lint:: i.llib-lmemmgr.ln
i.llib-lmemmgr.ln:: llib-lmemmgr.ln
	@if [ -d $(LOCALLINTLIBDIR) ]; then set +x; \
	else (set -x; $(MKDIRHIER) $(LOCALLINTLIBDIR)); fi
	$(INSTALL) -c $(INSTLIBFLAGS) llib-lmemmgr.ln $(LOCALLINTLIBDIR)/llib-lmemmgr.ln

install:: i.memmgr.h
i.memmgr.h:: memmgr.h
	@if [ -d $(LOCALINCLUDEROOT) ]; then set +x; \
	else (set -x; $(MKDIRHIER) $(LOCALINCLUDEROOT)); fi
	$(INSTALL) -c $(INSTINCFLAGS) memmgr.h $(LOCALINCLUDEROOT)/memmgr.h

depend::
	$(DEPEND) -s "# DO NOT DELETE" -- $(ALLINCLUDES) $(ALLDEFINES) -- $(SRCS)

all::
World::
	@echo "Building "$(PROJECTNAME)", Release "$(PROJECTRELEASE)
	@echo ""
	@date
	@echo ""
	$(MAKE) $(MFLAGS) Makefile
	$(MAKE) $(MFLAGS) Makefiles
	$(MAKE) $(MFLAGS) clean
	$(MAKE) $(MFLAGS) depend
	$(MAKE) $(MFLAGS) all
	@echo ""
	@date
	@echo ""
	@echo "Done building "$(PROJECTNAME)

# documentation

memmgr.ps:: memmgr.ms
	$(SOELIM) memmgr.ms  | $(TROFF) $(MSMACROS) $(TROFFOPTS) > memmgr.ps

clean::
	$(RM) memmgr.ps

# -------------------------------------------------------------------------
# common rules for all Makefiles

emptyrule::

clean::
	$(RM_CMD) "#"*

tags::
	$(TAGS) -w *.[ch]
	$(TAGS) -xw *.[ch] > TAGS

Makefile::
	$(IMBOOT_CMD) $(TOP) $(CURRENT_DIR)

help::
	@echo "'make Makefile' to rebuild Makefile"
	@echo "'make all' to make everything"
	@echo "'make target' to make a single target"
	@echo "'make depend' to generate header file dependencies"
	@echo "'make install' to install everything (except manual pages)"
	@echo "'make install.man' to install all manual pages"
	@echo "'make i.target' to install a single target"
	@echo "'make lint' to lint source files"
	@echo "'make lint.target' to lint source files for a single target"
	@echo "'make clean' to clean up"

# -------------------------------------------------------------------------
# empty rules for directories that do not have SUBDIRS

all::
depend::
lint::

install::
	@echo "install in $(CURRENT_DIR) done"

install.man::
	@echo "install.man in $(CURRENT_DIR) done"

Makefiles::

# -------------------------------------------------------------------------
# dependencies generated by makedepend

# DO NOT DELETE

alloc.o: /usr/include/stdio.h /usr/local/include/etm.h memmgr.internal.h
alloc.o: memmgr.h
allocnp.o: /usr/include/stdio.h memmgr.internal.h memmgr.h
stralloc.o: /usr/include/stdio.h /usr/local/include/etm.h memmgr.internal.h
stralloc.o: memmgr.h
strallocnp.o: /usr/include/stdio.h memmgr.internal.h memmgr.h
realloc.o: /usr/include/stdio.h /usr/local/include/etm.h memmgr.internal.h
realloc.o: memmgr.h
reallocnp.o: /usr/include/stdio.h memmgr.internal.h memmgr.h
valloc.o: /usr/include/stdio.h /usr/local/include/etm.h memmgr.internal.h
valloc.o: memmgr.h
vallocnp.o: /usr/include/stdio.h memmgr.internal.h memmgr.h
free.o: /usr/include/stdio.h memmgr.internal.h memmgr.h
::::::::::::::
README
::::::::::::::
This directory contains source and documentation for the MemMgr
memory management library.  You need the Exception and Termination
Manager (ETM) distribution to use MemMgr.  If you use the Imakefile,
you must obtain the WRPRC Release 2 imake configuration files.
If you just use the Makefile you will have to edit some of the
variable definitions.  Use "make -n" and "make -n install" to see
what will happen on your machine first!

The document memmgr.ms is formatted with the -ms macros.

The ETM and WRPRC2 configuration distributions are available via anonymous
ftp to host ftp.primate.wisc.edu under ~ftp/pub.

16 Oct 91	Paul DuBois	dubois@primate.wisc.edu

16 Oct 91 Release 1.00
20 Oct 91 Release 1.01
25 Oct 91 Release 1.02
01 Sep 93 Release 1.03
::::::::::::::
alloc.c
::::::::::::::
/*
	Panic version of AllocNP().
*/

# include	<stdio.h>

# include	"etm.h"

# include	"memmgr.internal.h"
# include	"memmgr.h"


char *Alloc (size)
int	size;
{
char	*p;

	if ((p = AllocNP (size)) == (char *) NULL)
		ETMPanic ("Alloc: out of memory");
	return (p);
}
::::::::::::::
allocnp.c
::::::::::::::
/*
	Allocate a piece of memory and return a pointer to it, or NULL
	if insufficient memory is available.
*/

# include	<stdio.h>

# include	"memmgr.internal.h"
# include	"memmgr.h"


char *AllocNP (size)
int	size;
{
	return ((char *) malloc ((allocSizeType) size));
}
::::::::::::::
free.c
::::::::::::::
/*
	Free a hunk of memory returned by one of the other MemMgr routines.
	It's safe to pass NULL to this routine.
*/

# include	<stdio.h>

# include	"memmgr.internal.h"
# include	"memmgr.h"


void Free (p)
char	*p;
{
	if (p != (char *) NULL)
		(void) free ((allocPtrType *) p);
}
::::::::::::::
memmgr.h
::::::::::::::
/*
	memmgr.h - memory management library header file
*/


/*
	These defines cause failure at link time if this header
	file wasn't included in each source file using MemMgr
	functions.
*/

# define	AllocNP		AllocNP_
# define	Alloc		Alloc_
# define	StrAllocNP	StrAllocNP_
# define	StrAlloc	StrAlloc_
# define	VAllocNP	VAllocNP_
# define	VAlloc		VAlloc_
# define	ReallocNP	ReallocNP_
# define	Realloc		Realloc_
# define	Free		Free_

extern char	*AllocNP ();
extern char	*Alloc ();
extern char	*StrAlloc ();
extern char	*StrAllocNP ();
extern char	*VAllocNP ();
extern char	*VAlloc ();
extern char	*Realloc ();
extern char	*ReallocNP ();
extern void	Free ();
::::::::::::::
memmgr.internal.h
::::::::::::::


extern char	*strcpy ();

# if defined(__STDC__) || defined(THINK_C)
# include	<stdlib.h>
# define	allocPtrType	void
# define	allocSizeType	size_t
#  else /* !THINK_C */
# ifdef	SYSV
# include	<malloc.h>
# define	allocPtrType	void
# define	allocSizeType	size_t
# else	/* !SYSV */
# define	allocPtrType	char
# define	allocSizeType	unsigned
extern allocPtrType	*calloc ();
extern allocPtrType	*malloc ();
extern allocPtrType	*realloc ();
# endif /* SYSV */
# endif /* THINK_C */


# define	allocSiz	1024
::::::::::::::
memmgr.ms
::::::::::::::
.\"
.\" xroff -ms % | lpr
.\"
.\" revision date - change whenever this file is edited
.ds RD 25 October 1991
.nr PO 1.2i	\" page offset 1.2 inches
.nr PD .7v	\" inter-paragraph distance
.\"
.EH 'Memory Manager Library'- % -''
.OH ''- % -'Memory Manager Library'
.OF 'Revision date:\0\0\*(RD''Printed:\0\0\n(dy \*(MO 19\n(yr'
.EF 'Revision date:\0\0\*(RD''Printed:\0\0\n(dy \*(MO 19\n(yr'
.\"
.\" I - italic font (taken from -ms and changed)
.de I
.nr PQ \\n(.f
.if t \&\\$3\\f2\\$1\\fP\&\\$2
.if n .if \\n(.$=1 \&\\$1
.if n .if \\n(.$>1 \&\\$1\c
.if n .if \\n(.$>1 \&\\$2
..
.de IS	\" interface routine description header start
.DS L
.ta .8i
.ft B
..
.de IE	\" interface routine description header end
.DE
.ft R
..
.TL
MemMgr \*- A Simple Memory Management Library
.sp .5v
.ps -2
Release 1.02
.AU
Paul DuBois
dubois@primate.wisc.edu
.AI
Wisconsin Regional Primate Research Center
Revision date:\0\0\*(RD
.NH
Introduction
.LP
.I 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
.I MemMgr
are two-fold.
.IP (i)
Minimize configuration burden on applications that dynamically allocate
memory.
For instance,
.I malloc()
on some systems returns a
.I char
pointer; on others it returns a
.I void
pointer.
The
.I MemMgr
library routines encapsulate system-specific configuration
differences and exports a fixed interface which is system-independent.
Once you compile and install it, you just use it without thinking about
whether your UNIX is System V or BSD inspired.
.IP (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.
.NH
Installation
.LP
This release of
.I MemMgr
is configured using
.I 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
.I imake ,
the
.I Makefile
is simple enough that you should be able to tweak it by hand.)
.LP
You also need to obtain and install the Exception/Termination Manager
(ETM) library to build this distribution.
.LP
If you are using
.I imake ,
take a look at the files in the
.I config
directory and change things if you want.
Then
build the distribution with ``make World'' or:
.LP
.DS
make Bootstrap
make depend
make
make install
.DE
.NH
Programming Interface
.LP
Source files for applications using
.I MemMgr
routines should include
.I memmgr.h .
.LP
Applications using
.I MemMgr
should be linked with
.I "\-lmemmgr \-letm" .
.IS
char *AllocNP (size)
int	size;
.IE
Allocate
.I 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.
.IS
char *Alloc (size)
int	size;
.IE
Like
.I Alloc() ,
but panics if insuffient memory is available.
.IS
char *StrAllocNP (s)
char	*s;
.IE
Allocates space for the string pointed to by
.I s
(including a null byte at the end),
copies the string into it, and returns a pointer to the copy.
Returns NULL if
.I s
is NULL or insufficient memory is available.
.IS
char *StrAlloc (s)
char	*s;
.IE
Like
.I StrAllocNP() ,
but panics if
.I s
is NULL or insuffient memory is available.
.IS
char *VAllocNP (count, size)
int	count, size;
.IE
Allocate
.I count
objects of
.I 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.
.IS
char *VAlloc (count, size)
int	count, size;
.IE
Like
.I VAlloc() ,
but panics if insuffient memory is available.
.IS
char *ReallocNP (p, size)
char	*p;
int	size;
.IE
Reallocate the block of memory pointed to by
.I p
to be
.I size
bytes long, free
.I p
and return a pointer to the new block.
.I p
should have been allocated by one of the other
.I MemMgr
routines.
Returns NULL if insufficient memory is available; in this case the
block pointed to by
.I p
is
.B not
freed.
Also returns NULL if
.I p
is NULL.
.IS
char *Realloc (p, size)
char	*p;
int	size;
.IE
Like
.I Realloc() ,
but panics if
.I p
is NULL or insuffient memory is available.
.IS
void Free (p)
char	*p;
.IE
Frees the chunk of memory pointed to by
.I p ;
the memory should have been allocated by one of the other
.I MemMgr
routines, with the exception that it is safe to pass NULL to
.I Free() .
.NH
Distribution and Update Availability
.LP
The
.I MemMgr
distribution may be freely circulated and is available for
anonymous FTP access under the
.I ~ftp/pub
directory on host
.I ftp.primate.wisc.edu .
Updates appear there as they become available.
.LP
The ETM and WRPRC configuration distributions are available on
.I ftp.primate.wisc.edu
as well.
.LP
If you do not have FTP access, send requests to the address
.I software@primate.wisc.edu .
Bug reports, questions, suggestions and comments may be sent to
this address as well.
::::::::::::::
realloc.c
::::::::::::::
/*
	Panic version of ReallocNP().
*/

# include	<stdio.h>

# include	"etm.h"

# include	"memmgr.internal.h"
# include	"memmgr.h"


char *Realloc (p, size)
char	*p;
int	size;
{
	if (p == (char *) NULL)
		ETMPanic ("Realloc: null pointer");
	if ((p = ReallocNP (p, size)) == (char *) NULL)
		ETMPanic ("Realloc: out of memory");
	return (p);
}
::::::::::::::
reallocnp.c
::::::::::::::
/*
	Reallocate p to size, free old memory and return pointer to new.
	If can't allocate the memory, returns NULL, and the old memory is
	NOT freed.
*/

# include	<stdio.h>

# include	"memmgr.internal.h"
# include	"memmgr.h"


char *ReallocNP (p, size)
char	*p;
int	size;
{
char	*s;

	if (p == (char *) NULL)
		return ((char *) NULL);
	if ((s = (char *) realloc (p, size)) == (char *) NULL)
		return ((char *) NULL);
	/*Free (p);*/	/* <- whoops! */
	return (s);
}
::::::::::::::
stralloc.c
::::::::::::::
/*
	Panic version of StrAllocNP().
*/

# include	<stdio.h>

# include	"etm.h"

# include	"memmgr.internal.h"
# include	"memmgr.h"


char *StrAlloc (s)
char	*s;
{
char	*p;

	if (s == (char *) NULL)
		ETMPanic ("StrAlloc: trying to copy null pointer");
	if ((p = StrAllocNP (s)) == (char *) NULL)
		ETMPanic ("StrAlloc: out of memory");
	return (p);
}
::::::::::::::
strallocnp.c
::::::::::::::
/*
	Allocate space for a string, copy the string into it, and return
	a pointer to the copy, or NULL if couldn't get the memory.
*/

# include	<stdio.h>

# include	"memmgr.internal.h"
# include	"memmgr.h"


char *StrAllocNP (s)
char	*s;
{
char	*p;

	if (s == (char *) NULL)
		return ((char *) NULL);
	if ((p = AllocNP (strlen (s) + 1)) == (char *) NULL)
		return ((char *) NULL);
	return (strcpy (p, s));
}
::::::::::::::
valloc.c
::::::::::::::
/*
	Panic version of VAllocNP().
*/

# include	<stdio.h>

# include	"etm.h"

# include	"memmgr.internal.h"
# include	"memmgr.h"


char *VAlloc (count, size)
int	count, size;
{
char	*p;

	if ((p = VAllocNP (count, size)) == (char *) NULL)
		ETMPanic ("VAlloc: out of memory");
	return (p);
}
::::::::::::::
vallocnp.c
::::::::::::::
/*
	Allocate a piece of memory to hold "count" elements of size "size",
	and return a pointer to it, or NULL if insufficient memory is
	available.
*/

# include	<stdio.h>

# include	"memmgr.internal.h"
# include	"memmgr.h"


char *VAllocNP (count, size)
int	count, size;
{
	return ((char *) calloc (count, (allocSizeType) size));
}
