Data Structures | Typedefs | Functions
tommyalloc.h File Reference

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...
 

Detailed Description

Allocator of fixed size blocks.

Typedef Documentation

Allocator of fixed size blocks.

Function Documentation

void tommy_allocator_init ( tommy_allocator alloc,
tommy_size_t  block_size,
tommy_size_t  align_size 
)

Initializes the allocator.

Parameters
allocAllocator to initialize.
block_sizeSize of the block to allocate.
align_sizeMinimum 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.

Parameters
allocAllocator to deinitialize.
void* tommy_allocator_alloc ( tommy_allocator alloc)

Allocates a block.

Parameters
allocAllocator 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.

Parameters
allocAllocator to use.
ptrBlock to free.
tommy_size_t tommy_allocator_memory_usage ( tommy_allocator alloc)

Gets the size of allocated memory.

Parameters
allocAllocator to use.