...
lib_mem.h/lib_mem.c
Prototype
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
void Mem_PoolCreate (MEM_POOL *pmem_pool,
void *pmem_base_addr,
CPU_SIZE_T mem_size,
MEM_POOL_BLK_QTY blk_nbr,
CPU_SIZE_T blk_size,
CPU_SIZE_T blk_align,
CPU_SIZE_T *poctets_reqd,
LIB_ERR *perr);
|
Arguments
pmem_pool
Pointer to a memory pool structure to create.
...
pmem_pool
must be passed a valid pointer to the address of a declared MEM_POOL
variable.
Example Usage
Code Block | ||
---|---|---|
Language | C++ | CaptionText | CAPTION
| ||
MEM_POOL AppMemPoolFromHeap; MEM_POOL AppMemPoolFromUserMemSeg; CPU_SIZE_T octets_reqd; LIB_ERR err; Mem_PoolCreate((MEM_POOL *)&AppMemPoolFromHeap, (void *) 0, /* Create pool from heap ... */ (CPU_SIZE_T ) 0u, (MEM_POOL_BLK_QTY) 10u, /* ... with 10 blocks ... */ (CPU_SIZE_T )100u, /* ... of 100 octets each ... */ (CPU_SIZE_T ) 4u, /* ... and align each block to a 4-byte boundary. */ (CPU_SIZE_T *)&octets_reqd, (LIB_ERR *)&err); if (err != LIB_ERR_NONE) { printf("COULD NOT CREATE MEMORY POOL."); if (err == LIB_MEM_ERR_HEAP_EMPTY) { printf("Heap empty ... %u more octets needed.", octets_reqd); } return; } Mem_PoolCreate((MEM_POOL *)&AppMemPoolFromUserMemSeg, (void *)0x21000000, /* Create pool from memory at 0x21000000 ... */ (CPU_SIZE_T )10000u, /* ... from a 10000-octet segment ... */ (MEM_POOL_BLK_QTY) 10u, /* ... with 10 blocks ... */ (CPU_SIZE_T ) 100u, /* ... of 1 00 octets each ... */ (CPU_SIZE_T ) 4u, /* ... and align each block to a 4-byte boundary. */ (CPU_SIZE_T *)&octets_reqd, (LIB_ERR *)&err); if (err != LIB_ERR_NONE) { printf("COULD NOT CREATE MEMORY POOL."); if (err == LIB_MEM_ERR_HEAP_EMPTY) { printf("Heap empty ... %u more octets needed.", octets_reqd); } else if (err == LIB_MEM_ERR_SEG_EMPTY) { printf("Segment empty ... %u more octets needed.", octets_reqd); } return; } |
...