-
Notifications
You must be signed in to change notification settings - Fork 0
man mem_pool_ex
mem_pool - Memory Pool API
#include "mem_pool.h"
typedef struct {
uint32_t* tpool;
uint32_t tlength;
uint32_t curcur;
} MPool;
void MPool_Ex_Tryshrink(MPool* pool,void* buf,uint32_t nlength);
char MPool_Ex_Trygrow(MPool* pool,void* buf,uint32_t nlength);
void MPool_Ex_FreeCleanup(MPool* pool,void* buf);
void *MPool_Ex_AllocJoin(MPool* pool,uint32_t length);
void MPool_Ex_ResetAllocCursor(MPool* pool);
The MPool_Ex functions are extension to the MPool_ Api to manage the memory much more efficient.
The MPool_Ex_Tryshrink() function shrinks a memory sub-block, similar to realloc().
The MPool_Ex_Trygrow() function grows a memory, block similar to realloc(). If it fails, it returns 0, else it was successful.
The MPool_Ex_FreeCleanup() function frees a memory sub-block like MPool_Free(), but, unlike MPool_Free(), it joins the freed memory block with the following freed memory blocks as possible.
The MPool_Ex_AllocJoin() function allocates new memory like MPool_Allocate(), but, unlike MPool_Allocate(), it joins freed memory-segments as needed.
The MPool_Ex_ResetAllocCursor() function resets the curcur field (Current memory Cursor) so the Allocation functions can be continue on the start of memory block.
None.