Data Structures | |
struct | _lub_blockpool |
struct | _lub_blockpool_stats |
Typedefs | |
typedef _lub_blockpool_block | lub_blockpool_block_t |
typedef _lub_blockpool | lub_blockpool_t |
typedef _lub_blockpool_stats | lub_blockpool_stats_t |
Functions | |
void | lub_blockpool_init (lub_blockpool_t *blockpool, void *memory, size_t blocksize, unsigned blockcount) |
void * | lub_blockpool_alloc (lub_blockpool_t *blockpool) |
void | lub_blockpool_free (lub_blockpool_t *blockpool, void *block) |
void | lub_blockpool__get_stats (lub_blockpool_t *instance, lub_blockpool_stats_t *stats) |
This type of memory manager is very fast and doesn't suffer from any memory fragmentation problems.
This allocator uses block 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.
The client is responsible for providing the memory to be managed.
typedef struct _lub_blockpool_stats lub_blockpool_stats_t |
This type defines the statistics available for each blockpool.
typedef struct _lub_blockpool lub_blockpool_t |
This type represents a "blockpool" instance.
void lub_blockpool__get_stats | ( | lub_blockpool_t * | instance, | |
lub_blockpool_stats_t * | stats | |||
) |
This operation fills out a statistics structure with the details for the specified blockpool.
instance | The instance on which to operate |
stats | A client provided structure to fill out with the blockpool details |
void* lub_blockpool_alloc | ( | lub_blockpool_t * | blockpool | ) |
This operation allocates a "block" of memory from a "blockpool"
blockpool | the "blockpool" instance to invoke this operation upon |
void lub_blockpool_free | ( | lub_blockpool_t * | blockpool, | |
void * | block | |||
) |
This operation de-allocates a "block" of memory back into a "blockpool"
blockpool | the "blockpool" instance to invoke this operation upon |
block | the "block" to release back to the pool |
void lub_blockpool_init | ( | lub_blockpool_t * | blockpool, | |
void * | memory, | |||
size_t | blocksize, | |||
unsigned | blockcount | |||
) |
This operation initialises an instance of a blockpool.
Following initialisation the allocation of memory can be performed.
blockpool | the "blockpool" instance to initialise. |
memory | the memory to be managed. |
blocksize | The size in bytes of each block. |
blockcount | The number of blocks to be managed. NB the client is responsible for ensuring that (blocksize x blockcount) bytes of memory are available for use. |