QP/C
Functions
qmp_get.c File Reference

QMPool_get() and QF_getPoolMargin() implementation. More...

#include "qf_pkg.h"
#include "qassert.h"

Go to the source code of this file.

Functions

void * QMPool_get (QMPool *me)
 Obtains a memory block from a memory pool.
uint32_t QF_getPoolMargin (uint8_t poolId)
 This function returns the margin of the given event pool.

Detailed Description

QMPool_get() and QF_getPoolMargin() implementation.

Definition in file qmp_get.c.


Function Documentation

uint32_t QF_getPoolMargin ( uint8_t  poolId)

This function returns the margin of the given event pool.

This function returns the margin of the given event pool poolId, where poolId is the ID of the pool initialized by the call to QF_poolInit(). The poolId of the first initialized pool is 1, the second 2, and so on.

The returned pool margin is the minimal number of free blocks encountered in the given pool since system startup.

Note:
Requesting the margin of an un-initialized pool raises an assertion in the QF.

Definition at line 65 of file qmp_get.c.

References Q_REQUIRE, QF_maxPool_, and QF_pool_.

void* QMPool_get ( QMPool me)

Obtains a memory block from a memory pool.

The only parameter me is a pointer to the QMPool from which the block is requested. The function returns a pointer to the allocated memory block or NULL if no free blocks are available.

A allocated block must be returned to the same pool from which it has been allocated.

This function can be called from any task level or ISR level.

Note:
The memory pool me must be initialized before any events can be requested from it. Also, the QMPool_get() function uses internally a QF critical section, so you should be careful not to call it from within a critical section when nesting of critical section is not supported.
See also:
QMPool_put()

Definition at line 40 of file qmp_get.c.

References QS_BEGIN_NOCRIT_, QS_END_NOCRIT_, QS_mpObj_, QS_OBJ_, QS_QF_MPOOL_GET, and QS_TIME_.