GFXprim
2D bitmap graphics library with emphasis on speed and correctness
|
Simple block allocator. More...
Go to the source code of this file.
Data Structures | |
struct | gp_balloc_pool |
A block allocator block header. More... | |
Typedefs | |
typedef struct gp_balloc_pool | gp_balloc_pool |
A block allocator block header. | |
Functions | |
void * | gp_balloc (gp_balloc_pool **self, size_t size) |
Allocate memory from a block pool. | |
void | gp_bfree (gp_balloc_pool **self) |
Free all blocks in the allocator. | |
Simple block allocator.
This is simple allocator for cases where we want to free all memory at once.
The allocator allocates memory in size pre-defined blocks and hands out memory from such pools until the block memory is exhausted. The allocator does not have to maintain free blocks, since all memory is freed at once, which makes the code super simple and fast.
Definition in file gp_block_alloc.h.
void * gp_balloc | ( | gp_balloc_pool ** | self, |
size_t | size | ||
) |
Allocate memory from a block pool.
The pointer to the gp_balloc has to be set to NULL prior first call to this function.
self | A pointer to a block pointer. |
size | A memory size to be allocated. |
void gp_bfree | ( | gp_balloc_pool ** | self | ) |
Free all blocks in the allocator.
self | A pointer to a block pointer. |