Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Gets a memory pool’s remaining segment size available to allocate.

Warning

This function is deprecated and will be removed in a future version of this product.

Files

lib_mem.h/lib_mem.c

Prototype

C++
Code Block
Language
CaptionTextCAPTION
languagecpp
          CPU_SIZE_T  Mem_SegGetSizeRem (MEM_POOL    *pmem_pool,
                                         CPU_SIZE_T   align,
                                         LIB_ERR     *perr);


Arguments

pmem_pool

Pointer to a memory pool structure.

...

Required Configuration

Available only if if LIB_MEM_CFG_ALLOCHEAP_EN is DEF_ENABLED SIZE is > 0 in lib_cfg.h (see section 4-4).

Notes / Warnings

Remaining size of memory segments returned from either memory segment’s configured dedicated memory, if any, or heap memory pool, otherwise.

Example Usage

CAPTION
Code Block
LanguageC++
CaptionText
languagecpp
MEM_POOL    AppMemPoolFromHeap;
MEM_POOL    AppMemPoolFromUserMemSeg;
CPU_SIZE_T  octets_reqd;
CPU_SIZE_T  size_rem;
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) {
    size_rem = Mem_SegGetSizeRem(&AppMemPoolFromHeap, 4u, &err);
    if (err == LIB_ERR_NONE) {
        printf("%u more octets available.", size_rem);
    }
}
 
 
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  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) {
    size_rem = Mem_SegGetSizeRem(&AppMemPoolFromUserMemSeg, 4u, &err);
    if (err == LIB_ERR_NONE) {
        printf("%u more octets available.", size_rem);
    }
}

...