chiark
/
gitweb
/
~mdw
/
mLib
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Test driver for associations.
[mLib]
/
man
/
alloc.3
diff --git
a/man/alloc.3
b/man/alloc.3
index bc345f13ed970046f64df44c1d6ec121f119c18d..295ae2c837eb3f5426d8ee355046a026d75a5436 100644
(file)
--- a/
man/alloc.3
+++ b/
man/alloc.3
@@
-9,9
+9,15
@@
alloc \- mLib low-level memory allocation
.nf
.B "#include <mLib/alloc.h>"
.nf
.B "#include <mLib/alloc.h>"
+.BI "void *x_alloc(arena *" a ", size_t " sz );
+.BI "char *x_strdup(arena *" a ", const char *" s );
+.BI "void *x_realloc(arena *" a ", void *" p ", size_t " sz ", size_t " osz );
+.BI "void x_free(arena *" a ", void *" p );
+
.BI "void *xmalloc(size_t " sz );
.BI "void *xmalloc(size_t " sz );
-.BI "void *xrealloc(void *" p ", size_t " sz );
+.BI "void *xrealloc(void *" p ", size_t " sz
", size_t " osz
);
.BI "char *xstrdup(const char *" s );
.BI "char *xstrdup(const char *" s );
+.BI "void xfree(void *" p );
.fi
.SH DESCRIPTION
These functions allocate and return blocks of memory. If insufficient
.fi
.SH DESCRIPTION
These functions allocate and return blocks of memory. If insufficient
@@
-19,52
+25,38
@@
memory is available, an
.B EXC_NOMEM
exception is raised.
.PP
.B EXC_NOMEM
exception is raised.
.PP
-The
-.B xmalloc
-and
-.B xrealloc
-functions are veneers over the standard
-.BR malloc (3)
+The functions
+.BR x_alloc ,
+.BR x_realloc ,
+.BR x_strdup
and
and
-.BR realloc (3)
-functions.
-.B xmalloc
-allocates a block of
-.I sz
-bytes and returns a pointer to the base of the block;
-.B xrealloc
-is given a pointer
-.I p
-to a block of memory, and returns the address of a new block of size
-.I sz
-bytes with the same contents as the original one (either truncated, if
-the new block is smaller, or padded with rubbish at the end if bigger).
+.BR x_free
+work with a given arena (see
+.BR arena (3)).
+.B x_alloc
+allocates a block of a given size;
+.B x_realloc
+resizes an allocated block;
+.B x_strdup
+allocates a copy of a null-terminated string; and
+.B x_free
+releases a block.
+.RB ( x_free
+is supplied for orthogonality's sake: it's equivalent to calling the
+.BR A_FREE (3)
+macro.)
.PP
The
.PP
The
-.B xstrdup
-function allocates and returns a block of memory containing a copy of
-the null-terminated string
-.IR p .
-The block is just large enough for the string and its null terminator.
-.PP
-The memory blocks allocated by these functions can be released by
-calling the standard
-.BR free (3)
-function.
-.SH "RETURN VALUE"
-The
.BR xmalloc ,
.BR xmalloc ,
-.B xrealloc
+.BR xrealloc ,
+.BR xstrdup
and
and
-.B xstrdup
-functions return pointers to the blocks they allocated. They do not
-return if a block couldn't be allocated; instead, the exception
-.B EXC_NOMEM
-is raised.
+.BR xfree
+macros are provided as a convenient interface to failsafe memory
+allocation from the current arena
+.BR arena_global (3).
.SH "SEE ALSO"
.SH "SEE ALSO"
-.BR malloc (3),
-.BR realloc (3),
-.BR free (3),
+.BR arena (3),
.BR exc (3),
.BR mLib (3).
.SH AUTHOR
.BR exc (3),
.BR mLib (3).
.SH AUTHOR