@@@ fltfmt mess
[mLib] / mem / arena.3.in
index 11aa308..09207fa 100644 (file)
 .TH arena 3mLib "3 June 2000" "Straylight/Edgeware" "mLib utilities library"
 .\" @arena_global
 .\" @arena_stdlib
+.
 .\" @arena_fakemalloc
-.\" @a_alloc
-.\" @a_realloc
-.\" @a_free
+.
+.\" @ALLOCV_SAFE_P
+.\" @NEWV_SAFE_P
+.
 .\" @A_ALLOC
+.\" @A_ALLOCV
+.\" @A_NEW
+.\" @A_NEWV
 .\" @A_REALLOC
+.\" @A_RENEWV
 .\" @A_FREE
 .
+.\" @a_alloc
+.\" @a_allocv
+.\" @a_realloc
+.\" @a_reallocv
+.\" @a_free
+.
 .\"--------------------------------------------------------------------------
 .SH "NAME"
 arena \- control of memory allocation
@@ -68,12 +80,28 @@ arena \- control of memory allocation
 .BI "void *arena_fakerealloc(arena *" a ", void *" p ,
 .BI "  size_t " sz ", size_t " osz );
 .PP
+.BI "int ALLOCV_SAFE_P(size_t " n ", size_t " sz );
+.BI "int NEWV_SAFE_P(" type " *" p ", size_t " n );
+.PP
 .BI "void *a_alloc(arena *" a ", size_t " sz );
+.BI "void *a_allocv(arena *" a ", size_t " n ", size_t " sz );
 .BI "void *a_realloc(arena *" a ", void *" p ", size_t " sz ", size_t " osz );
+.ta \w'\fBvoid a_reallocv('u
+.BI "void *a_reallocv(arena *" a ", void *" p ,
+.BI "  size_t " n ", size_t " on ", size_t " sz );
 .BI "void a_free(arena *" a );
 .PP
 .BI "void *A_ALLOC(arena *" a ", size_t " sz );
+.BI "void *A_ALLOCV(arena *" a ", size_t " n ", size_t " sz );
+.BI "void A_NEW(" type " *" p ", arena *" a );
+.BI "void A_NEWV(" type " *" p ", arena *" a ", size_t " n );
 .BI "void *A_REALLOC(arena *" a ", void *" p ", size_t " sz ", size_t " osz );
+.ta \w'\fBvoid A_REALLOCV('u
+.BI "void *A_REALLOCV(arena *" a ", void *" p ,
+.BI "  size_t " n ", size_t " on ", size_t " sz );
+.ta \w'\fBvoid A_RENEWV('u
+.BI "void A_RENEWV(" type " *" q ", " type " *" p ", arena *" a ,
+.BI "  size_t " n ", size_t " on ", size_t " sz );
 .BI "void A_FREE(arena *" a );
 .fi
 .
@@ -119,6 +147,68 @@ function has an extra argument
 specifying the old size of the block.  This is for the benefit of arena
 handlers which can't easily find the old block's size.
 .PP
+The macro
+.B ALLOCV_SAFE_P
+returns nonzero if the product
+.IR n "\ \(mu\ " sz
+is representable in type
+.B size_t
+and zero otherwise;
+i.e., it returns true if it would be safe to try to allocate
+.IR n "\ \(mu\ " sz
+bytes.
+The macro
+.BR A_ALLOCV
+allocates space for an array of
+.I n
+elements each of size
+.IR sz ,
+somewhat like
+.BR calloc (3),
+except that
+.B A_ALLOCV
+does not clear the allocated memory.
+Likewise, the macro
+.B A_REALLOCV
+resizes the block pointed to by
+.IR p ,
+which previously had space for
+.I on
+elements of size
+.IR sz ,
+so that it now has enough space for
+.I n
+elements,
+returning the new block address.
+There are also function-call equivalents of these macros.
+.PP
+Finally, the macro
+.B A_NEW
+sets its argument
+.I p
+to point to a freshly allocated block of memory
+large enough for the type that
+.I p
+points to,
+or to null if allocation failed.
+The macro
+.B A_NEWV
+sets
+.I p
+to point to memory large enough for
+.I n
+elements, each of the type that
+.I p
+points to.
+The macro
+.B A_RENEWV
+sets
+.I q
+to point to memory large enough for
+.I n
+elements, each of the type that
+.I p
+points to.
 .
 .SS "Defining new arenas"
 An