2 .TH arena 3 "3 June 2000" mLib
4 arena \- control of memory allocation
16 .B "#include <mLib/arena.h>"
18 .BI "arena *arena_global;"
19 .BI "arena arena_stdlib;"
21 .BI "void *arena_fakerealloc(arena *" a ", void *" p ", size_t " sz );
23 .BI "void *a_alloc(arena *" a ", size_t " sz );
24 .BI "void *a_realloc(arena *" a ", void *" p ", size_t " sz );
25 .BI "void a_free(arena *" a );
27 .BI "void *A_ALLOC(arena *" a ", size_t " sz );
28 .BI "void *A_REALLOC(arena *" a ", void *" p ", size_t " sz );
29 .BI "void A_FREE(arena *" a );
34 is a place from which blocks of memory may be allocated and freed. The
37 library provides a single standard arena,
43 calls. The global variable
45 is a pointer to a `current' arena, which is a good choice to use if
46 you can't think of anything better.
53 behave like the standard C functions
58 allocating, resizing and releasing blocks from a given arena. There are
59 function-call equivalents with lower-case names too. For a more
60 convenient interface to memory allocation, see
63 .SS "Defining new arenas"
66 is a structure containing a single member,
68 which is a pointer to a structure of type
72 structure may be followed in memory by data which is used by the arena's
73 manager to maintain its state.
77 table contains function pointers which are called to perform various
78 memory allocation tasks:
80 .BI "void *(*" alloc ")(arena *" a ", size_t " sz );
81 Allocates a block of memory, of at least
83 bytes in size, appropriately aligned, and returns its address.
85 .BI "void *(*" realloc ")(arena *" a ", void *" p ", size_t " sz );
86 Resizes the block pointed to by
88 so that it is at least
90 bytes long. You can use
92 here, to fake resizing by allocating, copying and freeing, if your arena
93 doesn't make doing something more efficient easy.
95 .BI "void (*" free ")(arena *" a ", void *" p );
96 Frees the block pointed to by
99 .BI "void (*" purge ")(arena *" a );
100 Frees all blocks in the arena. Used when the arena is being destroyed.
107 calls with respect to null pointers and zero-sized blocks is as
108 specified by the ANSI C standard.
113 Mark Wooding, <mdw@nsict.org>