Data Structures | |
struct | _lub_dblockpool |
Typedefs | |
typedef _lub_dblockpool | lub_dblockpool_t |
Functions | |
void | lub_dblockpool_init (lub_dblockpool_t *instance, size_t blocksize, unsigned chunksize, unsigned max_chunks) |
void | lub_dblockpool_fini (lub_dblockpool_t *instance) |
void * | lub_dblockpool_alloc (lub_dblockpool_t *instance) |
void | lub_dblockpool_free (lub_dblockpool_t *instance, void *block) |
It dynamically allocates chunks of memory each of which is used as a "blockpool". This dynamic memory is taken from the standard heap via "malloc()".
This type of memory manager is very fast and doesn't suffer from any memory fragmentation problems.
This allocator can reuse blocks in the order in which they are freed, this is significant for some applications where you don't want to re-use a particular freed block too soon. e.g. hardware timing limits on re-use.
typedef struct _lub_dblockpool lub_dblockpool_t |
This type represents a "dblockpool" instance.
void* lub_dblockpool_alloc | ( | lub_dblockpool_t * | instance | ) |
This operation allocates a "block" of memory from a "dblockpool"
instance | the "dblockpool" instance to operate on |
void lub_dblockpool_fini | ( | lub_dblockpool_t * | instance | ) |
This operation finalises an instance of a dblockpool.
instance | the "dblockpool" instance to finalise. |
void lub_dblockpool_free | ( | lub_dblockpool_t * | instance, | |
void * | block | |||
) |
This operation de-allocates a "block" of memory back into a "blockpool"
instance | the "blockpool" instance to invoke this operation upon |
block | the "block" to release back to the pool |
void lub_dblockpool_init | ( | lub_dblockpool_t * | instance, | |
size_t | blocksize, | |||
unsigned | chunksize, | |||
unsigned | max_chunks | |||
) |
This operation initialises an instance of a dblockpool.
Following initialisation the allocation of memory can be performed.
instance | the "dblockpool" instance to initialise. |
blocksize | The size in bytes of each block. |
chunksize | The number of blocks to be managed in a chunk. |
max_chunks | The maximum number of chunks to be allocated. (a value of zero means unlimited...) |