6#ifndef IT_D4NP_MEMORYPOOL_MEMORY_POOL_H_
7#define IT_D4NP_MEMORYPOOL_MEMORY_POOL_H_
42#ifndef PBR_MEMORY_POOL_DIAGNOSTICS
44#define PBR_MEMORY_POOL_DIAGNOSTICS 0
46#define PBR_MEMORY_POOL_DIAGNOSTICS 1
63#define PBR_MEMORY_POOL_THREAD_SAFETY_NONE 0
64#define PBR_MEMORY_POOL_THREAD_SAFETY_MUTEX 1
65#define PBR_MEMORY_POOL_THREAD_SAFETY_LOCKFREE 2
66#ifndef PBR_MEMORY_POOL_THREAD_SAFETY
67#define PBR_MEMORY_POOL_THREAD_SAFETY PBR_MEMORY_POOL_THREAD_SAFETY_NONE
242#if PBR_MEMORY_POOL_DIAGNOSTICS
void * memory_pool_alloc(memory_pool_t *pool)
Allocate one block from pool in O(1).
struct memory_pool memory_pool_t
Opaque handle to a memory pool instance.
void memory_pool_destroy(memory_pool_t *pool)
Destroy pool and release every byte of pre-allocated backing storage back to the operating system,...
size_t memory_pool_debug_free_count(const memory_pool_t *pool)
Diagnostics — count the free slots currently in pool's free list by walking it in O(free_count) (ADR-...
size_t memory_pool_metadata_bytes(const memory_pool_t *pool)
Report the per-pool metadata overhead in bytes (spec section 3.2 / ADR-0015).
memory_pool_t * memory_pool_create(size_t block_size, size_t block_count)
Create a memory pool able to vend block_count blocks of block_size bytes each.
size_t memory_pool_growths(const memory_pool_t *pool)
Report how many times pool has grown — i.e.
const void * memory_pool_debug_free_list_head(const memory_pool_t *pool)
Diagnostics — return the head of pool's implicit free list (ADR-0019 §2).
size_t memory_pool_block_size(const memory_pool_t *pool)
Report the configured per-block size of pool in bytes (ADR-0018 §3).
memory_pool_t * memory_pool_create_dynamic(size_t block_size, size_t block_count, size_t growth_factor)
Create a memory pool in dynamic-growth mode (spec section 2.2): when exhausted it acquires a new cont...
const void * memory_pool_debug_free_list_next(const memory_pool_t *pool, const void *current)
Diagnostics — given a free slot current obtained from memory_pool_debug_free_list_head or a previous ...
void memory_pool_free(memory_pool_t *pool, void *block)
Return a previously allocated block to pool in O(1).