MFS is an manually managed pool class for small objects of fixed size.
Unlike other manual pool classes, it is not subject to internal fragmentation.
The implementation is very simple: unlike other pool classes which store their control structures separately from the allocated blocks, MFS maintains a stack of free blocks using a pointer in the free block. mps_alloc() pops this stack and mps_free() pushes it.
#include "mpscmfs.h"
Return the pool class for an MFS (Manual Fixed Small) pool.
When creating an MFS pool, mps_pool_create_k() requires one keyword arguments:
In addition, mps_pool_create_k() may take:
For example:
MPS_ARGS_BEGIN(args) {
MPS_ARGS_ADD(ARGS, MPS_KEY_MFS_UNIT_SIZE, 1024);
MPS_ARGS_ADD(ARGS, MPS_KEY_EXTEND_BY, 1024 * 1024);
MPS_ARGS_DONE(args);
res = mps_pool_create_k(&pool, arena, mps_class_mfs(), args);
} MPS_ARGS_END(args);
Deprecated
starting with version 1.112.
When using mps_pool_create(), pass the segment size and unit size like this:
mps_res_t mps_pool_create(mps_pool_t *pool_o, mps_arena_t arena,
mps_class_t mps_class_mfs(),
mps_size_t extend_size,
mps_size_t unit_size)