mempool: add API for malloc semantics
This works like k_malloc() but allows the user to designate a specific memory pool to use instead of the kernel heap. Test coverage provided by existing tests for k_malloc(), which is now derived from this API. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
c8010e4877
commit
a2480bd472
3 changed files with 56 additions and 33 deletions
|
@ -3652,6 +3652,17 @@ struct k_mem_pool {
|
|||
extern int k_mem_pool_alloc(struct k_mem_pool *pool, struct k_mem_block *block,
|
||||
size_t size, s32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Allocate memory from a memory pool with malloc() semantics
|
||||
*
|
||||
* Such memory must be released using k_free().
|
||||
*
|
||||
* @param pool Address of the memory pool.
|
||||
* @param size Amount of memory to allocate (in bytes).
|
||||
* @return Address of the allocated memory if successful, otherwise NULL
|
||||
*/
|
||||
extern void *k_mem_pool_malloc(struct k_mem_pool *pool, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Free memory allocated from a memory pool.
|
||||
*
|
||||
|
@ -3702,7 +3713,8 @@ extern void *k_malloc(size_t size);
|
|||
* @brief Free memory allocated from heap.
|
||||
*
|
||||
* This routine provides traditional free() semantics. The memory being
|
||||
* returned must have been allocated from the heap memory pool.
|
||||
* returned must have been allocated from the heap memory pool or
|
||||
* k_mem_pool_malloc().
|
||||
*
|
||||
* If @a ptr is NULL, no operation is performed.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue