3 .\" Manual for general memory allocation
5 .\" (c) 1999--2002, 2005, 2009, 2024 Straylight/Edgeware
8 .\"----- Licensing notice ---------------------------------------------------
10 .\" This file is part of the mLib utilities library.
12 .\" mLib is free software: you can redistribute it and/or modify it under
13 .\" the terms of the GNU Library General Public License as published by
14 .\" the Free Software Foundation; either version 2 of the License, or (at
15 .\" your option) any later version.
17 .\" mLib is distributed in the hope that it will be useful, but WITHOUT
18 .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 .\" License for more details.
22 .\" You should have received a copy of the GNU Library General Public
23 .\" License along with mLib. If not, write to the Free Software
24 .\" Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
27 .\"--------------------------------------------------------------------------
28 .so ../defs.man \" @@@PRE@@@
30 .\"--------------------------------------------------------------------------
31 .TH alloc 3mLib "8 May 1999" "Straylight/Edgeware" "mLib utilities library"
41 .\"--------------------------------------------------------------------------
43 alloc \- mLib low-level memory allocation
45 .\"--------------------------------------------------------------------------
49 .B "#include <mLib/alloc.h>"
51 .BI "void *x_alloc(arena *" a ", size_t " sz );
52 .BI "char *x_strdup(arena *" a ", const char *" s );
53 .BI "void *x_realloc(arena *" a ", void *" p ", size_t " sz ", size_t " osz );
54 .BI "void x_free(arena *" a ", void *" p );
56 .BI "void *xmalloc(size_t " sz );
57 .BI "void *xrealloc(void *" p ", size_t " sz ", size_t " osz );
58 .BI "char *xstrdup(const char *" s );
59 .BI "void xfree(void *" p );
62 .\"--------------------------------------------------------------------------
65 These functions allocate and return blocks of memory. If insufficient
66 memory is available, an
76 work with a given arena (see
79 allocates a block of a given size;
81 resizes an allocated block;
83 allocates a copy of a null-terminated string; and
87 is supplied for orthogonality's sake: it's equivalent to calling the
97 macros are provided as a convenient interface to failsafe memory
98 allocation from the current arena
101 .\"--------------------------------------------------------------------------
108 .\"--------------------------------------------------------------------------
111 Mark Wooding, <mdw@distorted.org.uk>
113 .\"----- That's all, folks --------------------------------------------------