Skip to content
maxymania edited this page Mar 24, 2013 · 1 revision

NAME

mem_pool - Memory Pool API

SYNOPSIS

#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);

DESCRIPTION

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.

EXAMPLES

None.

SEE ALSO

man mem_pool

Clone this wiki locally