10. MV (Manual Variable)

MV is a general-purpose manually managed pool class that manages blocks of variable size.

10.1. MV properties

10.2. MV interface

#include "mpscmv.h"
mps_pool_class_t mps_class_mv(void)

Return the pool class for an MV (Manual Variable) pool.

When creating an MV pool, mps_pool_create_k() takes four optional keyword arguments:

  • MPS_KEY_ALIGN (type mps_align_t, default is MPS_PF_ALIGN) is the alignment of the addresses allocated (and freed) in the pool. The minimum alignment supported by pools of this class is 1 (one) and the maximum is the arena grain size (see MPS_KEY_ARENA_GRAIN_SIZE).

  • MPS_KEY_EXTEND_BY (type size_t, default 65536) is the size of block that the pool will request from the arena.

  • MPS_KEY_MEAN_SIZE (type size_t, default 32) is the predicted mean size of blocks that will be allocated from the pool. This value must be smaller than, or equal to, the value for MPS_KEY_EXTEND_BY.

  • MPS_KEY_MAX_SIZE (type size_t, default 65536) is the predicted maximum size of blocks that will be allocated from the pool. This value must be larger than, or equal to, the value for MPS_KEY_EXTEND_BY.

The mean and maximum sizes are hints to the MPS: the pool will be less efficient if these are wrong, but nothing will break.

For example:

MPS_ARGS_BEGIN(args) {
    MPS_ARGS_ADD(args, MPS_KEY_MEAN_SIZE, 32);
    MPS_ARGS_ADD(args, MPS_KEY_MAX_SIZE, 1024);
    MPS_ARGS_ADD(args, MPS_KEY_EXTEND_BY, 1024 * 1024);
    res = mps_pool_create_k(&pool, arena, mps_class_mfs(), args);
} MPS_ARGS_END(args);
mps_pool_class_t mps_class_mv_debug(void)

A debugging version of the MV pool class.

When creating a debugging MV pool, mps_pool_create_k() takes five optional keyword arguments: MPS_KEY_ALIGN, MPS_KEY_EXTEND_SIZE, MPS_KEY_MEAN_SIZE, MPS_KEY_MAX_SIZE are as described above, and MPS_KEY_POOL_DEBUG_OPTIONS specifies the debugging options. See mps_pool_debug_option_s.