OS  v7.3.3
Documentation
Memory Management

API interface for the Memory Management extension. More...

Collaboration diagram for Memory Management:

Data Structures

struct  qMemMang_Pool_t
 A Memory Pool object. More...
 

Functions

qBool_t qMemMang_Pool_Setup (qMemMang_Pool_t *const mPool, void *pArea, const size_t pSize)
 Initializes a memory pool instance. This function should be called once before any heap memory request. More...
 
qBool_t qMemMang_Pool_Select (qMemMang_Pool_t *const mPool)
 Select the memory pool to perform heap memory requests with qMalloc() and qFree(). More...
 
size_t qMemMang_Get_FreeSize (qMemMang_Pool_t *mPool)
 Returns the total amount of heap space that remains unallocated for the selected memory pool. More...
 
void * qMemMang_Allocate (qMemMang_Pool_t *mPool, size_t pSize)
 Allocate a block of memory that is pSize bytes large. Allocation will be performed in the selected memory pool. If the requested memory can be allocated, a pointer is returned to the beginning of the memory block. More...
 
qBool_t qMemMang_Free (qMemMang_Pool_t *mPool, void *ptr)
 Deallocates previously allocated space from the memory pool. If ptr is a NULL pointer, the function does nothing. The behavior is undefined if selected memory pool has not been initialized. The behavior is undefined if the value of ptr does not equal a value returned earlier by qMalloc(). The behavior is undefined if the memory area referred to by ptr has already been deallocated, that is, qFree() has already been called with ptr as the argument and no calls to qMalloc() resulted in a pointer equal to ptr afterwards. The behavior is undefined if after qFree() returns, an access is made through the pointer ptr. More...
 
void * qMalloc (size_t mSize)
 Wrapper API for qMemMang_Allocate() in order to be compatible with malloc(). Allocate a block of memory that is mSize bytes large. Allocation will be performed in the selected memory pool. If the requested memory can be allocated, a pointer is returned to the beginning of the memory block. More...
 
void qFree (void *ptr)
 Wrapper API for qMemMang_Free() in order to be compatible with free(). Deallocates the space previously allocated by qMalloc(). Deallocation will be performed in the selected memory pool. If ptr is a null pointer, the function does nothing. The behavior is undefined if selected memory pool has not been initialized. The behavior is undefined if the value of ptr does not equal a value returned earlier by qMalloc(). The behavior is undefined if the memory area referred to by ptr has already been deallocated, that is, qFree() has already been called with ptr as the argument and no calls to qMalloc() resulted in a pointer equal to ptr afterwards. The behavior is undefined if after qFree() returns, an access is made through the pointer ptr. More...
 

Detailed Description

API interface for the Memory Management extension.

Function Documentation

◆ qFree()

void qFree ( void *  ptr)

Wrapper API for qMemMang_Free() in order to be compatible with free(). Deallocates the space previously allocated by qMalloc(). Deallocation will be performed in the selected memory pool. If ptr is a null pointer, the function does nothing. The behavior is undefined if selected memory pool has not been initialized. The behavior is undefined if the value of ptr does not equal a value returned earlier by qMalloc(). The behavior is undefined if the memory area referred to by ptr has already been deallocated, that is, qFree() has already been called with ptr as the argument and no calls to qMalloc() resulted in a pointer equal to ptr afterwards. The behavior is undefined if after qFree() returns, an access is made through the pointer ptr.

Attention
qFree() its NOT interrupt-safe.
Parameters
[in]ptrto the memory to deallocate
Returns
none.

◆ qMalloc()

void * qMalloc ( size_t  mSize)

Wrapper API for qMemMang_Allocate() in order to be compatible with malloc(). Allocate a block of memory that is mSize bytes large. Allocation will be performed in the selected memory pool. If the requested memory can be allocated, a pointer is returned to the beginning of the memory block.

Note
The behavior is undefined if selected memory pool has not been initialized.
Attention
qMalloc() its NOT interrupt-safe.
Parameters
[in]mSizeSize of the memory block in bytes.
Returns
If the request is successful then a pointer to the memory block is returned. If the function failed to allocate the requested block of memory, a NULL pointer is returned.

◆ qMemMang_Allocate()

void * qMemMang_Allocate ( qMemMang_Pool_t mPool,
size_t  pSize 
)

Allocate a block of memory that is pSize bytes large. Allocation will be performed in the selected memory pool. If the requested memory can be allocated, a pointer is returned to the beginning of the memory block.

Attention
qMemMang_Allocate() its NOT interrupt-safe.
Parameters
[in]mPoolA pointer to the memory pool instance.
[in]pSizeSize of the memory block in bytes.
Returns
If the request is successful then a pointer to the memory block is returned. If the function failed to allocate the requested block of memory , a NULL pointer is returned.

◆ qMemMang_Free()

qBool_t qMemMang_Free ( qMemMang_Pool_t mPool,
void *  ptr 
)

Deallocates previously allocated space from the memory pool. If ptr is a NULL pointer, the function does nothing. The behavior is undefined if selected memory pool has not been initialized. The behavior is undefined if the value of ptr does not equal a value returned earlier by qMalloc(). The behavior is undefined if the memory area referred to by ptr has already been deallocated, that is, qFree() has already been called with ptr as the argument and no calls to qMalloc() resulted in a pointer equal to ptr afterwards. The behavior is undefined if after qFree() returns, an access is made through the pointer ptr.

Attention
qMemMang_Free() its NOT interrupt-safe.
Parameters
[in]mPoolA pointer to the memory pool instance.
[in]ptrto the memory to deallocate
Returns
qTrue on success. Otherwise return qFalse.

◆ qMemMang_Get_FreeSize()

size_t qMemMang_Get_FreeSize ( qMemMang_Pool_t mPool)

Returns the total amount of heap space that remains unallocated for the selected memory pool.

Parameters
[in]mPoolA pointer to the memory pool instance. Pass NULL to select the default memory pool.
Returns
The size of the unallocated heap.

◆ qMemMang_Pool_Select()

qBool_t qMemMang_Pool_Select ( qMemMang_Pool_t *const  mPool)

Select the memory pool to perform heap memory requests with qMalloc() and qFree().

Parameters
[in]mPoolA pointer to the memory pool instance
Returns
qTrue on success. Otherwise return qFalse.

◆ qMemMang_Pool_Setup()

qBool_t qMemMang_Pool_Setup ( qMemMang_Pool_t *const  mPool,
void *  pArea,
const size_t  pSize 
)

Initializes a memory pool instance. This function should be called once before any heap memory request.

Parameters
[in]mPoolA pointer to the memory pool instance
[in]pAreaA pointer to a memory block uint8_t statically allocated to act as Heap of the memory pool. The size of this block should match the pSize argument.
[in]pSizeThe size of the memory block pointed by pArea
Returns
Returns qTrue on success, otherwise, returns qFalse.