6#ifndef VL_FIXEDPOOL_DEFAULT_SIZE
7#define VL_FIXEDPOOL_DEFAULT_SIZE 16
17#if defined(VL_U64_T) && defined(VL_U32_T)
18#define VL_FIXEDPOOL_INDEX_T VL_U64_T
19#define VL_FIXEDPOOL_ORDINAL_T VL_U32_T
20#define VL_FIXEDPOOL_SHIFT 32
21#define VL_FIXEDPOOL_LOOKUP_MAX 0xFFFFFFFF
22#define VL_FIXEDPOOL_MASK 0x00000000FFFFFFFF
23#define VL_FIXEDPOOL_INVALID_IDX 0xFFFFFFFFFFFFFFFF
24#elif defined(VL_U32_T) && defined(VL_U16_T)
25#define VL_FIXEDPOOL_INDEX_T VL_U32_T
26#define VL_FIXEDPOOL_ORDINAL_T VL_U16_T
27#define VL_FIXEDPOOL_SHIFT 16
28#define VL_FIXEDPOOL_LOOKUP_MAX 0xFFFF
29#define VL_FIXEDPOOL_MASK 0x0000FFFF
30#define VL_FIXEDPOOL_INVALID_IDX 0xFFFFFFFF
31#elif defined(VL_U16_T) && defined(VL_U8_T)
32#define VL_FIXEDPOOL_INDEX_T VL_U16_T
33#define VL_FIXEDPOOL_ORDINAL_T VL_U8_T
34#define VL_FIXEDPOOL_SHIFT 8
35#define VL_FIXEDPOOL_LOOKUP_MAX 0xFF
36#define VL_FIXEDPOOL_MASK 0x00FF
37#define VL_FIXEDPOOL_INVALID_IDX 0xFFFF
39#error Failed to configure vl_linearpool types.
47typedef struct vl_fixed_pool_node vl_fixed_pool_node;
57typedef struct vl_fixed_pool_node{
58 VL_FIXEDPOOL_ORDINAL_T totalTaken;
59 VL_FIXEDPOOL_ORDINAL_T blockSize;
60 VL_FIXEDPOOL_ORDINAL_T blockOrdinal;
61 vl_fixed_pool_node* nextLookup;
161#ifndef vlFixedPoolSample
169#define vlFixedPoolSample(pool, idx) (void*)(((vl_usmall_t*)((pool)->lookupTable[(idx) & VL_FIXEDPOOL_MASK])->elements) + (((idx) >> VL_FIXEDPOOL_SHIFT) * (pool)->elementSize))
void vlFixedPoolInit(vl_fixedpool *pool, vl_ularge_t elementSize)
Initializes the specified fixed pool instance.
Definition vl_fixed_pool.c:31
VL_FIXEDPOOL_INDEX_T vl_fixedpool_idx
Definition vl_fixed_pool.h:45
void vlFixedPoolDelete(vl_fixedpool *pool)
De-initializes and deletes the specified fixed pool. This will clear up all memory associated with me...
Definition vl_fixed_pool.c:242
vl_fixedpool_idx * freeStack
Definition vl_fixed_pool.h:95
vl_dsidx_t lookupCapacity
Definition vl_fixed_pool.h:91
vl_fixed_pool_node * lookupHead
Definition vl_fixed_pool.h:92
void vlFixedPoolFree(vl_fixedpool *pool)
De-initializes the specified pool instance.
Definition vl_fixed_pool.c:126
vl_dsidx_t freeCapacity
Definition vl_fixed_pool.h:94
void vlFixedPoolClear(vl_fixedpool *pool)
Definition vl_fixed_pool.c:115
vl_fixedpool_idx vlFixedPoolTake(vl_fixedpool *pool)
Definition vl_fixed_pool.c:55
vl_fixedpool * vlFixedPoolNew(vl_ularge_t elementSize)
Allocates and initializes a fixed pool instance.
Definition vl_fixed_pool.c:234
void vlFixedPoolReset(vl_fixedpool *pool)
Definition vl_fixed_pool.c:153
void vlFixedPoolReturn(vl_fixedpool *pool, vl_fixedpool_idx idx)
Definition vl_fixed_pool.c:91
vl_fixedpool_idx growthIncrement
Definition vl_fixed_pool.h:89
vl_fixedpool * vlFixedPoolClone(const vl_fixedpool *src, vl_fixedpool *dest)
Clones the specified source fixed pool.
Definition vl_fixed_pool.c:184
void vlFixedPoolReserve(vl_fixedpool *pool, vl_dsidx_t n)
Ensures space for n-many elements in the pool.
Definition vl_fixed_pool.c:174
vl_ularge_t elementSize
Definition vl_fixed_pool.h:88
A non-trivial pool allocator, useful for avoiding many smaller heap allocations.
Definition vl_fixed_pool.h:87
VL_STRUCTURE_INDEX_T vl_dsidx_t
Index type for data structures.
Definition vl_numtypes.h:13
VL_ULARGE_T vl_ularge_t
Largest available unsigned integer type.
Definition vl_numtypes.h:74