chiark / gitweb /
@@@ tvec and tty mess
[mLib] / mem / sub.3.in
index 0382fe0fc263eab711e764f18f9327f866ab02c1..14a22db4815d09bc3a47a6e9cddb5c4ec8cb9871 100644 (file)
 .
 .\" @A_CREATE
 .\" @A_DESTROY
+.\" @A_SUBNEW
 .\" @CREATE
 .\" @DESTROY
+.\" @NEW
 .
 .\"--------------------------------------------------------------------------
 .SH NAME
@@ -57,15 +59,16 @@ sub \- efficient allocation and freeing of small blocks
 .BI "void subarena_create(subarena *" s ", arena *" a );
 .BI "void subarena_destroy(subarena *" s );
 .BI "void subarena_alloc(subarena *" s ", size_t " sz );
+.BI "void *A_CREATE(subarena *" s ", " type );
+.BI "A_SUBNEW(" type "* " p ", subarena *" s );
 .BI "void subarena_free(subarena *" s ", void *" p ", size_t " sz );
+.BI "void A_DESTROY(subarena *" s ", " type " *" p );
 .PP
 .B "void sub_init(void);"
 .BI "void *sub_alloc(size_t " sz );
-.BI "void sub_free(void *" p ", size_t " sz );
-.PP
-.BI "void *A_CREATE(subarena *" s ", " type );
-.BI "void A_DESTROY(subarena *" s ", " type " *" p );
 .BI "void *CREATE(" type );
+.BI "NEW(" type "* " p );
+.BI "void sub_free(void *" p ", size_t " sz );
 .BI "void DESTROY(" type " *" p );
 .fi
 .
@@ -118,8 +121,9 @@ function using
 .BR subarena_free .
 If you do, you'll get what you deserve.
 .PP
-The pair of macros
-.B A_CREATE
+The macros
+.BR A_CREATE ,
+.BR A_SUBNEW ,
 and
 .B A_DESTROY
 are intended to provide a slightly more natural interface to
@@ -129,7 +133,12 @@ mystruct *p = subarena_alloc(s, sizeof(mystruct));
 .VE
 can be replaced by
 .VS
-mystruct p = A_CREATE(s, mystruct);
+mystruct *p = A_CREATE(s, mystruct);
+.VE
+or
+.VS
+mystruct *p;
+A_SUBNEW(p, s);
 .VE
 Similarly, the block can be freed by saying
 .VS
@@ -149,7 +158,8 @@ used).  The functions
 and
 .B sub_free
 and the macros
-.B CREATE
+.BI CREATE ,
+.BI NEW
 and
 .B DESTROY
 use this subarena.