b6b9d458 |
1 | .\" -*-nroff-*- |
fbf20b5b |
2 | .TH alloc 3 "8 May 1999" "Straylight/Edgeware" "mLib utilities library" |
08da152e |
3 | .\" @xmalloc |
4 | .\" @xrealloc |
5 | .\" @xstrdup |
b6b9d458 |
6 | .SH NAME |
7 | alloc \- mLib low-level memory allocation |
8 | .SH SYNOPSIS |
9 | .nf |
10 | .B "#include <mLib/alloc.h>" |
11 | |
b5ea4de3 |
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 ); |
cededfbe |
16 | |
b6b9d458 |
17 | .BI "void *xmalloc(size_t " sz ); |
b5ea4de3 |
18 | .BI "void *xrealloc(void *" p ", size_t " sz ", size_t " osz ); |
b6b9d458 |
19 | .BI "char *xstrdup(const char *" s ); |
cededfbe |
20 | .BI "void xfree(void *" p ); |
b6b9d458 |
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 |
cededfbe |
28 | The functions |
29 | .BR x_alloc , |
30 | .BR x_realloc , |
31 | .BR x_strdup |
b6b9d458 |
32 | and |
cededfbe |
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.) |
b6b9d458 |
48 | .PP |
49 | The |
b6b9d458 |
50 | .BR xmalloc , |
cededfbe |
51 | .BR xrealloc , |
52 | .BR xstrdup |
b6b9d458 |
53 | and |
cededfbe |
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). |
b6b9d458 |
58 | .SH "SEE ALSO" |
cededfbe |
59 | .BR arena (3), |
08da152e |
60 | .BR exc (3), |
61 | .BR mLib (3). |
b6b9d458 |
62 | .SH AUTHOR |
63 | Mark Wooding, <mdw@nsict.org> |
64 | |