This interface provides a facility to manage the allocation and deallocation of fixed sized blocks of memory.
More...
Detailed Description
This interface provides a facility to manage the allocation and deallocation of fixed sized blocks of memory.
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.
- Author:
- Graeme McKerrell
- Date:
- Created On : Fri Jan 23 12:50:18 2004
- Version:
- TESTED
Typedef Documentation
|
This type represents a "blockpool" instance. |
Function Documentation
|
This operation allocates a "block" of memory from a "blockpool"
- Precondition:
- The blockpool must have been initialised.
- Returns:
- A pointer to a "block" of memory, or NULL if there is none left for allocation.
- Postcondition:
- The behaviour is undefined if the "blockpool" is uninitialised.
- Parameters:
-
blockpool |
the "blockpool" instance to invoke this operation upon |
|
|
This operation de-allocates a "block" of memory back into a "blockpool"
- Precondition:
- The specified block must have been previously allocated using lub_blockpool_alloc()
- Postcondition:
- The de-allocated block become available for subsequent lub_blockpool_alloc() requests.
- Parameters:
-
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.
- Precondition:
- 'blocksize' must be an multiple of 'sizeof(void *)'. (If the client declares a structure for the block this should be handled automatically by the compiler)
- Postcondition:
- If the size constraint is not met an assert will fire.
Following initialisation the allocation of memory can be performed.
- Parameters:
-
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. |
|
Generated on Fri Jun 2 10:49:38 2006 for CLISH by
1.4.6