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