Next: , Previous: , Up: Top  


How to use

Using MemPool:

The include file "mempool.h" contains all exported functions. All functions in this library are thread-safe.

cyg_bool MemPool_init(cyg_uint32)

This function takes the requested size in bytes of the memory pool (up to 2GB) and returns true on success false if not enough memory. Call this function always first.

void MemPool_exit(void)

This function shuts the MemPool library down. All previously allocated memory gets released to the O/S. Call this function optionally on shutdown.

void MemPool_get_status(cyg_uint32 flags, struct Cyg_Mempool_Status* status)

This function returns current status about MemPool. The parameter flags is CYG_MEMPOOL_STAT_ALL or a combination of CYG_MEMPOOL_STAT_XXX (see mpcommon.h). *status is filled on return, and contains different usage statistics.

void* MemPool_Memory_Alloc_Func(cyg_uint32 size)

This function allocates a variable sized memory block out of the MemPool. It can be used to replace the malloc function.

void* MemPool_Memory_ReAlloc_Func(void* mem, cyg_uint32 new_size)

This function reallocates a variable sized memory block out of the MemPool. It can be used to replace the realloc function.

void MemPool_Memory_Free_Func(void* mem)

This function releases a variable sized memory block. It can be used to replace the free function.