FreeRTOS C-Addons  1.1.0
C-Addon functionality to FreeRTOS
Typedefs | Functions
mem_pool.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef void * MemoryPool_t
 

Functions

MemoryPool_t CreateMemoryPool (int itemSize, int itemCount, int Alignment)
 
int AddExtraMemoryToPool (MemoryPool_t pool, int ItemCount)
 
MemoryPool_t CreateMemoryPoolStatic (int ItemSize, void *PreallocatedMemory, int PreallocatedMemorySize, int Alignment)
 
int AddExtraMemoryToPoolStatic (MemoryPool_t pool, void *PreallocatedMemory, int PreallocatedMemorySize)
 
void * MemoryPoolAllocate (MemoryPool_t pool)
 
void MemoryPoolFree (MemoryPool_t pool, void *memory)
 

Typedef Documentation

◆ MemoryPool_t

typedef void* MemoryPool_t

Handle for memory pools.

These are fixed allocation size memory areas.

Definition at line 49 of file mem_pool.h.

Function Documentation

◆ AddExtraMemoryToPool()

int AddExtraMemoryToPool ( MemoryPool_t  pool,
int  ItemCount 
)

There is no DeleteMemoryPool() by design! Allows you to add extra memory to a pool.

Parameters
poolAn existing memory pool.
ItemCountHow many more items you want to add.
Returns
pdPASS on success, pdFAIL on error.

Definition at line 193 of file mem_pool.c.

◆ AddExtraMemoryToPoolStatic()

int AddExtraMemoryToPoolStatic ( MemoryPool_t  pool,
void *  PreallocatedMemory,
int  PreallocatedMemorySize 
)

Allows you to add extra memory to a pool.

Parameters
poolAn existing memory pool.
PreallocatedMemoryPointer to the preallocated memory you are dedicating to this pool.
PreallocatedMemorySizeHow big is the buffer you are passing in.
Returns
pdPASS on success, pdFAIL on error.

Definition at line 281 of file mem_pool.c.

◆ CreateMemoryPool()

MemoryPool_t CreateMemoryPool ( int  itemSize,
int  itemCount,
int  Alignment 
)

Create a MemoryPool

Parameters
itemSizeHow big is an allocation.
itemCountWhat's the maximum number of allocations allowed?
AlignmentPower of 2 value denoting on which address boundary the memory will be aligned to. Must be at least sizeof(unsigned char *).
Returns
A Handle to the pool, or NULL on failure.

Definition at line 140 of file mem_pool.c.

◆ CreateMemoryPoolStatic()

MemoryPool_t CreateMemoryPoolStatic ( int  ItemSize,
void *  PreallocatedMemory,
int  PreallocatedMemorySize,
int  Alignment 
)

Create a MemoryPool

Parameters
ItemSizeHow big is an allocation.
PreallocatedMemoryPointer to the preallocated memory you are dedicating to this pool.
PreallocatedMemorySizeHow big is the buffer you are passing in.
AlignmentPower of 2 value denoting on which address boundary the memory will be aligned to. Must be at least sizeof(unsigned char *).
Returns
A Handle to the pool, or NULL on failure.

Definition at line 230 of file mem_pool.c.

◆ MemoryPoolAllocate()

void* MemoryPoolAllocate ( MemoryPool_t  pool)

Get a memory buffer from the pool.

Note that this can block, and cannnot be used from ISR context.

Parameters
poolA handle to a MemoryPool.
Returns
A pointer or NULL on failure.

Definition at line 311 of file mem_pool.c.

◆ MemoryPoolFree()

void MemoryPoolFree ( MemoryPool_t  pool,
void *  memory 
)

Return a memory buffer to the pool.

Note
This can block, and cannnot be used from ISR context.
There is no check that the memory passed in is valid.
Parameters
poolA handle to a MemoryPool.
memorymemory obtained from MemoryPoolAllocate().

Definition at line 338 of file mem_pool.c.