cu/scratch.h: Scratch Memory for Repeated Reuse
[Utilities]
Detailed Description
This header defines a small object to manage reuse of a scratch memory area. It is mainly inteded to be defined in function bodies and used in inner loops when cu_salloc is not feasible.
Define Documentation
#define cu_scratch_cct cu_scratch_init |
#define CU_SCRATCH_INIT { 0, NULL } |
An initialiser which can be assigned in a declaration of a variable of type struct cu_scratch
.
Function Documentation
void* cu_scratch_alloc_log |
( |
cu_scratch_t |
scr, |
|
|
size_t |
size | |
|
) |
| | |
Extend scr to the maximum of size and twice the old size, unless the old size is at least size, and return a pointer to it's memory. Does not preserve the contents.
void* cu_scratch_alloc_min |
( |
cu_scratch_t |
scr, |
|
|
size_t |
size | |
|
) |
| | |
Extend scr to size unless it already is at least that big, and return a pointer to it's memory. Does not preserve the contents.
A pointer to the start of the scratch memory.
void* cu_scratch_realloc_log |
( |
cu_scratch_t |
scr, |
|
|
size_t |
size | |
|
) |
| | |
void* cu_scratch_realloc_min |
( |
cu_scratch_t |
scr, |
|
|
size_t |
size | |
|
) |
| | |