chiark / gitweb /
Fix a large number of bugs.
[mLib] / man / alloc.3
1 .\" -*-nroff-*-
2 .TH alloc 3 "8 May 1999" "Straylight/Edgeware" "mLib utilities library"
3 .\" @xmalloc
4 .\" @xrealloc
5 .\" @xstrdup
6 .SH NAME
7 alloc \- mLib low-level memory allocation
8 .SH SYNOPSIS
9 .nf
10 .B "#include <mLib/alloc.h>"
11
12 .BI "void *x_alloc(arena *" a ", size_t " sz );
13 .BI "char *x_strdup(arena *" a ", const char *" s );
14 .BI "void *x_realloc(arena *" a ", void *" p ", size_t " sz ", size_t " osz );
15 .BI "void x_free(arena *" a ", void *" p );
16
17 .BI "void *xmalloc(size_t " sz );
18 .BI "void *xrealloc(void *" p ", size_t " sz ", size_t " osz );
19 .BI "char *xstrdup(const char *" s );
20 .BI "void xfree(void *" p );
21 .fi
22 .SH DESCRIPTION
23 These functions allocate and return blocks of memory.  If insufficient
24 memory is available, an
25 .B EXC_NOMEM
26 exception is raised.
27 .PP
28 The functions
29 .BR x_alloc ,
30 .BR x_realloc ,
31 .BR x_strdup
32 and
33 .BR x_free
34 work with a given arena (see
35 .BR arena (3)).
36 .B x_alloc
37 allocates a block of a given size;
38 .B x_realloc
39 resizes an allocated block;
40 .B x_strdup
41 allocates a copy of a null-terminated string; and
42 .B x_free
43 releases a block.
44 .RB ( x_free
45 is supplied for orthogonality's sake: it's equivalent to calling the
46 .BR A_FREE (3)
47 macro.)
48 .PP
49 The
50 .BR xmalloc ,
51 .BR xrealloc ,
52 .BR xstrdup
53 and
54 .BR xfree
55 macros are provided as a convenient interface to failsafe memory
56 allocation from the current arena
57 .BR arena_global (3).
58 .SH "SEE ALSO"
59 .BR arena (3),
60 .BR exc (3),
61 .BR mLib (3).
62 .SH AUTHOR
63 Mark Wooding, <mdw@nsict.org>
64