PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches
pool.h File Reference
#include <stdatomic.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/defs.h>
Include dependency graph for pool.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  pool_t
 Pool structure. More...
 

Macros

#define POOL_IDX_MAX   UINT16_MAX
 The maximum index value for pool.
 
#define POOL_TAG_INC   ((uint64_t)(POOL_IDX_MAX) + 1)
 The amount to increment the tag by in the tagged free list.
 

Typedefs

typedef uint16_t pool_idx_t
 Pool index type.
 

Functions

void pool_init (pool_t *pool, void *elements, size_t capacity, size_t elementSize, size_t nextOffset)
 Initialize a pool.
 
pool_idx_t pool_alloc (pool_t *pool)
 Allocate an element from the pool.
 
void pool_free (pool_t *pool, pool_idx_t idx)
 Free an element back to the pool.