Versions Compared

Key

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

Gets a memory pool’s remaining number of blocks 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

CaptionText
Code Block
LanguageC++
CAPTIONlanguagecpp
          MEM_POOL_BLK_QTY  Mem_PoolBlkGetNbrAvail (MEM_POOL  *pmem_pool,
                                                    LIB_ERR   *perr)


Arguments

pmem_pool

Pointer to a memory pool structure.

...

Mem_PoolBlkGetNbrAvail() ONLY supports non-heap memory pools. Mem_HeapGetSizeRem()/Mem_SegGetSizeRem() should be used for heap memory pool/segment (see section 4-4-3 and section 4-4-4).

Example Usage

CAPTION
Code Block
LanguageC++
CaptionText
languagecpp
MEM_POOL           AppMemPool;
CPU_SIZE_T         octets_reqd;
void              *pmem_blk;
MEM_POOL_BLK_QTY   nbr_blk_rem;
LIB_ERR            err;


Mem_PoolCreate((MEM_POOL       *)&AppMemPool,
             (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.");
    return;
}

                                                 /* Get an 80-byte memory block from the pool.     */
pmem_blk = Mem_PoolBlkGet(&AppMemPool, 80u, &err);
if (err != LIB_ERR_NONE) {
  printf("COULD NOT GET MEMORY BLOCK FROM MEMORY POOL.");
    return;
}

                                                 /* Get number of remaining memory pool blocks.    */
nbr_blk_rem = Mem_PoolBlkGetNbrAvail(&AppMemPool, &err);
if (err == LIB_ERR_NONE) {
  printf("%u more blocks available.", nbr_blk_rem);
}

...