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