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 | |
| TOMMY_API void | tommy_allocator_init (tommy_allocator *alloc, tommy_size_t block_size, tommy_size_t align_size) |
| Initializes the allocator. More... | |
| TOMMY_API void | tommy_allocator_done (tommy_allocator *alloc) |
| Deinitializes the allocator. More... | |
| TOMMY_API void * | tommy_allocator_alloc (tommy_allocator *alloc) |
| Allocates a block. More... | |
| TOMMY_API void | tommy_allocator_free (tommy_allocator *alloc, void *ptr) |
| Deallocates a block. More... | |
| TOMMY_API 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.
| TOMMY_API 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*). |
| TOMMY_API void tommy_allocator_done | ( | tommy_allocator * | alloc | ) |
Deinitializes the allocator.
It also releases all the allocated memory to the heap.
| alloc | Allocator to deinitialize. |
| TOMMY_API void * tommy_allocator_alloc | ( | tommy_allocator * | alloc | ) |
Allocates a block.
| alloc | Allocator to use. |
| TOMMY_API 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_API tommy_size_t tommy_allocator_memory_usage | ( | tommy_allocator * | alloc | ) |
Gets the size of allocated memory.
| alloc | Allocator to use. |