QuakeForge  0.7.2.210-815cf
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
High-tide allocator.

Macros

#define ALLOC(s, t, n, v)
 High-tide structure allocator for use in linked lists. More...
 
#define FREE(n, p)
 Free a block allocated by ALLOC. More...
 

Detailed Description

Macro Definition Documentation

#define ALLOC (   s,
  t,
  n,
 
)

High-tide structure allocator for use in linked lists.

Using a free-list with the name of NAME_freelist, return a single element. The type of the element must be a structure with a field named next. When the free-list is empty, memory is claimed from the system in blocks. Elements may be returned to the pool by linking them into the free-list.

Parameters
sThe number of structures in the block.
tThe structure type.
nThe NAME portion of the NAME_freelist free-list.
vThe destination of the pointer to the allocated element. The contents of the allocated element will be memset to 0.
#define FREE (   n,
 
)
Value:
do { \
p->next = n##_freelist; \
n##_freelist = p; \
} while (0)
#define n(x, y)

Free a block allocated by ALLOC.

Parameters
nThe NAME portion of the NAME_freelist free-list.
pThe pointer to the block to be freed.