A linear memory allocator for uBlink modules.
Example Workflow
A blink_pool must be initialised (or reinitialised) before use:
uint8_t heap[1024U];
(void)BLINK_PoolInit(&pool,
heap,
sizeof(
heap));
Allocate a word aligned block:
assert(memory != NULL);
assert(*memory == 0);
*memory = 42;
Find out how much memory can still be allocated:
|
typedef struct blink_pool * | blink_pool_t |
| This type shall be used by uBlink modules to refer to initialised pools.
|
|
Data Fields |
uint8_t * |
heap |
pointer to assigned heap |
size_t |
pos |
free memory offset |
size_t |
size |
size of heap in bytes |
Allocate word aligned memory from the pool.
- Note
- memory shall be set to zero at allocation time
- Parameters
-
[in] | self | initialsed pool |
[in] | size | number of bytes to allocate |
- Returns
- pointer to allocated memory
- Return values
-
NULL | insufficient free memory |
- Examples:
- tc_blink_pool.c.
Discover how much free memory is left in the pool.
- Parameters
-
- Returns
- free space in bytes
- Examples:
- tc_blink_pool.c.
This function will initialise a blink_pool_static structure.
- Parameters
-
[in] | self | |
[in] | heap | A pointer to word aligned memory block that will be used as the heap. |
[in] | size | The size of the heap memory block in bytes. |
- Returns
- intialised blink_pool_static
- Examples:
- tc_blink_pool.c.