qmpool.h File Reference

platform-independent memory pool interface. More...

Go to the source code of this file.

Data Structures

struct  QMPool
 Native QF Memory Pool. More...

Defines

#define QF_MPOOL_SIZ_SIZE   2
 macro to override the default QMPoolSize size. Valid values 1, 2, or 4; default 2
#define QF_MPOOL_CTR_SIZE   2
 macro to override the default QMPoolCtr size. Valid values 1, 2, or 4; default 2

Functions

void QMPool_init (QMPool *me, void *poolSto, uint32_t poolSize, QMPoolSize blockSize)
 Initializes the native QF event pool.
void * QMPool_get (QMPool *me)
 Obtains a memory block from a memory pool.
void QMPool_put (QMPool *me, void *b)
 Returns a memory block back to a memory pool.

Detailed Description

platform-independent memory pool interface.

This header file must be included in all QF ports that use native QF memory pool implementation.

Definition in file qmpool.h.


Function Documentation

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_NOLOCK_, QS_END_NOLOCK_, QS_mpObj_, QS_OBJ_, and QS_QF_MPOOL_GET.

void QMPool_init ( QMPool me,
void *  poolSto,
uint32_t  poolSize,
QMPoolSize  blockSize 
)

Initializes the native QF event pool.

The parameters are as follows: me points to the QMPool struct to be initialized, poolSto is the pool storage, poolSize is the size of the pool storage in bytes, and blockSize is the block size of this pool.

The caller of this method must make sure that the poolSto pointer is properly aligned. In particular, it must be possible to efficiently store a pointer at the location pointed to by poolSto. Internally, the QMPool_init() function rounds up the block size blockSize so that it can fit an integer number of pointers. This is done to achieve proper alignment of the blocks within the pool.

Note:
Due to the rounding of block size the actual capacity of the pool might be less than (poolSize / blockSize). You can check the capacity of the pool by calling the QF_getPoolMargin() function.

Definition at line 40 of file qmp_init.c.

References Q_ASSERT, Q_REQUIRE, QS_BEGIN_, QS_END_, QS_INT_LOCK_KEY_, QS_mpObj_, QS_OBJ_, and QS_QF_MPOOL_INIT.

void QMPool_put ( QMPool me,
void *  b 
)

Returns a memory block back to a memory pool.

The first parameter me is a pointer to the QMPool to which the block is returned. The second parameter is the pointer to the returned memory block.

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

Note:
The block must be allocated from the same memory pool to which it is returned. The QMPool_put() function raises an assertion if the returned pointer to the block points outside of the original memory buffer managed by the memory pool. Also, the QMPool_put() 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_get()

Definition at line 40 of file qmp_put.c.

References Q_REQUIRE, QS_BEGIN_NOLOCK_, QS_END_NOLOCK_, QS_mpObj_, QS_OBJ_, and QS_QF_MPOOL_PUT.

Generated on Tue Mar 16 19:38:11 2010 for QP/C by  doxygen 1.6.3