Allocator of fixed size blocks. More...
Go to the source code of this file.
Data Structures | |
struct | tommy_allocator_struct |
Allocator of fixed size blocks. More... | |
Typedefs | |
typedef struct tommy_allocator_struct | tommy_allocator |
Allocator of fixed size blocks. More... | |
Functions | |
void | tommy_allocator_init (tommy_allocator *alloc, tommy_size_t block_size, tommy_size_t align_size) |
Initializes the allocator. More... | |
void | tommy_allocator_done (tommy_allocator *alloc) |
Deinitialize the allocator. More... | |
void * | tommy_allocator_alloc (tommy_allocator *alloc) |
Allocates a block. More... | |
void | tommy_allocator_free (tommy_allocator *alloc, void *ptr) |
Deallocates a block. More... | |
tommy_size_t | tommy_allocator_memory_usage (tommy_allocator *alloc) |
Gets the size of allocated memory. More... | |
Allocator of fixed size blocks.
typedef struct tommy_allocator_struct tommy_allocator |
Allocator of fixed size blocks.
void tommy_allocator_init | ( | tommy_allocator * | alloc, |
tommy_size_t | block_size, | ||
tommy_size_t | align_size | ||
) |
Initializes the allocator.
alloc | Allocator to initialize. |
block_size | Size of the block to allocate. |
align_size | Minimum alignment requirement. No less than sizeof(void*). |
void tommy_allocator_done | ( | tommy_allocator * | alloc | ) |
Deinitialize the allocator.
It also releases all the allocated memory to the heap.
alloc | Allocator to deinitialize. |
void* tommy_allocator_alloc | ( | tommy_allocator * | alloc | ) |
Allocates a block.
alloc | Allocator to use. |
void tommy_allocator_free | ( | tommy_allocator * | alloc, |
void * | ptr | ||
) |
Deallocates a block.
You must use the same allocator used in the tommy_allocator_alloc() call.
alloc | Allocator to use. |
ptr | Block to free. |
tommy_size_t tommy_allocator_memory_usage | ( | tommy_allocator * | alloc | ) |
Gets the size of allocated memory.
alloc | Allocator to use. |