chiark / gitweb /
url: Allow `;' to separate key/value pairs in URL-encoded strings.
[mLib] / man / alloc.3
index c0793f0dfd6dbd8032e8ff0213d14422f67abb8e..06ad53df33636ac28a28578d94ae8a2db537f195 100644 (file)
@@ -1,14 +1,28 @@
 .\" -*-nroff-*-
-.TH alloc 3mLib "8 May 1999" "mLib"
+.TH alloc 3 "8 May 1999" "Straylight/Edgeware" "mLib utilities library"
+.\" @xmalloc
+.\" @xrealloc
+.\" @xstrdup
+.\" @xfree
+.\" @x_alloc
+.\" @x_strdup
+.\" @x_realloc
+.\" @x_free
 .SH NAME
 alloc \- mLib low-level memory allocation
 .SH SYNOPSIS
 .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 *xrealloc(void *" p ", size_t " sz );
+.BI "void *xrealloc(void *" p ", size_t " sz ", size_t " osz );
 .BI "char *xstrdup(const char *" s );
+.BI "void xfree(void *" p );
 .fi
 .SH DESCRIPTION
 These functions allocate and return blocks of memory.  If insufficient
@@ -16,53 +30,40 @@ memory is available, an
 .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
-.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
-.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 ,
-.B xrealloc
+.BR xrealloc ,
+.BR xstrdup
 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"
-.BR malloc (3),
-.BR realloc (3),
-.BR free (3),
-.BR exc (3mLib).
+.BR arena (3),
+.BR exc (3),
+.BR mLib (3).
 .SH AUTHOR
-Mark Wooding, <mdw@nsict.org>
+Mark Wooding, <mdw@distorted.org.uk>