kiba-engine
|
Linear allocator implementation. More...
Go to the source code of this file.
Data Structures | |
struct | linear_allocator_block |
Internal state of the linear_allocator. More... | |
Typedefs | |
typedef struct linear_allocator_block | linear_allocator_block |
Internal state of the linear_allocator. More... | |
Functions | |
linear_allocator_block * | linear_allocator_block_create (usize size, linear_allocator_block *next) |
Create a new linear_allocator_block. More... | |
b8 | linear_allocator_create (allocator *alloc, usize size) |
void | linear_allocator_destroy (allocator *alloc) |
void * | linear_allocator_allocate (allocator *alloc, usize size) |
void | linear_allocator_free (allocator *alloc, void *mem, usize size) |
void | linear_allocator_free_all (allocator *alloc) |
Linear allocator implementation.
Definition in file linear.c.
typedef struct linear_allocator_block linear_allocator_block |
Internal state of the linear_allocator.
Memory is managed as a linked list. The initial memory block provides at least the requested amount of memory. It will add a new block to the list if the old one is either full or a requested allocation cannot be served with the current blocks. New blocks are added to the start of the list.
void* linear_allocator_allocate | ( | allocator * | alloc, |
usize | size | ||
) |
Definition at line 88 of file linear.c.
linear_allocator_block * linear_allocator_block_create | ( | usize | size, |
linear_allocator_block * | next | ||
) |
Create a new linear_allocator_block.
Initializes cur_offset to 0.
size | minimum size of the memory area |
next | the next block in the linked list |
b8 linear_allocator_create | ( | allocator * | alloc, |
usize | size | ||
) |
Definition at line 60 of file linear.c.
void linear_allocator_destroy | ( | allocator * | alloc | ) |
void linear_allocator_free | ( | allocator * | alloc, |
void * | mem, | ||
usize | size | ||
) |
void linear_allocator_free_all | ( | allocator * | alloc | ) |