Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

Creates a dynamic memory pool.

Files

lib_mem.h/lib_mem.c

Prototype

Arguments

p_name

Pointer to pool name.

p_pool

Pointer to pool data.

p_seg

Pointer to segment from which to allocate memory. Passing DEF_NULL will allocate memory from the general-purpose heap.

blk_size

Size of memory block to allocate from pool, in bytes. See Note #1.

blk_align

Required alignment of memory block, in bytes. MUST be a power of 2.

blk_qty_init

Initial number of elements to be allocated in pool.

blk_qty_max

Maximum number of elements that can be allocated from this pool. Set to LIB_MEM_BLK_QTY_UNLIMITED if no limit.

p_err

Pointer to variable that will receive the return error code from this function.

LIB_MEM_ERR_NONE

LIB_MEM_ERR_INVALID_BLK_ALIGN

LIB_MEM_ERR_INVALID_BLK_SIZE

LIB_MEM_ERR_INVALID_BLK_NBR

LIB_MEM_ERR_NULL_PTR

LIB_MEM_ERR_INVALID_MEM_ALIGN

LIB_MEM_ERR_INVALID_MEM_SIZE

LIB_MEM_ERR_NULL_PTR

LIB_MEM_ERR_SEG_OVF

Returned Value

None.

Required Configuration

None.

Notes / Warnings

  1. 'blk_size' must be big enough to fit a pointer since the pointer to the next free block is stored in the block itself (only when free/unused). 
  • No labels