40Q_DEFINE_THIS_MODULE(
"qf_mem")
44void QMPool_init(
QMPool * const me,
46 uint_fast32_t const poolSize,
47 uint_fast16_t const blockSize)
54 me->freeHead = (
void * *)poolSto;
57 me->blockSize = (
QMPoolSize)(2U *
sizeof(
void *));
58 uint_fast16_t inext = 2U;
59 while (me->blockSize < (
QMPoolSize)blockSize) {
68 void * *pfb = me->freeHead;
72 for (uint_fast32_t size = poolSize - me->blockSize;
73 size >= (uint_fast32_t)me->blockSize;
74 size -= (uint_fast32_t)me->blockSize)
83#if (QF_MPOOL_CTR_SIZE == 1U)
85#elif (QF_MPOOL_CTR_SIZE == 2U)
91 me->start = (
void * *)poolSto;
101 uint_fast16_t
const margin,
102 uint_fast8_t
const qsId)
119 void * *
const pfb_next = pfb[0];
133 (me->
start <= pfb_next) && (pfb_next <= me->
end));
145 pfb[0] = &me->
end[1];
174 uint_fast8_t
const qsId)
180 void * *
const pfb = (
void * *)block;
uint16_t QMPoolSize
The data type to store the block-size based on the macro QF_MPOOL_SIZ_SIZE.
uint16_t QMPoolCtr
The data type to store the block-counter based on the macro QF_MPOOL_CTR_SIZE.
#define Q_UNUSED_PAR(par_)
Helper macro to clearly mark unused parameters of functions.
Internal (package scope) QP/C interface.
#define QS_BEGIN_PRE(rec_, qsId_)
QP Functional Safety (FuSa) Subsystem.
#define Q_ASSERT_INCRIT(id_, expr_)
General-purpose assertion with user-specified ID number (in critical section)
#define Q_REQUIRE_INCRIT(id_, expr_)
Assertion for checking a precondition (in critical section)
void ** end
End of the memory managed by this memory pool.
void QMPool_put(QMPool *const me, void *const block, uint_fast8_t const qsId)
Recycles a memory block back to a memory pool.
void * QMPool_get(QMPool *const me, uint_fast16_t const margin, uint_fast8_t const qsId)
Obtain a memory block from a memory pool.
void ** start
Start of the memory managed by this memory pool.
QMPoolCtr volatile nFree
Number of free memory blocks remaining in the pool at this point.
QMPoolCtr nMin
Minimum number of free blocks ever present in this pool.
QMPoolCtr nTot
Total number of memory blocks in this pool.