Base/platform/inc-c/alloc/pool.h

33 lines
842 B
C
Raw Normal View History

#ifndef RR_POOL_PROVIDER_H
#define RR_POOL_PROVIDER_H
#include <librr/types.h>
#include <librr/alloc/generic.h>
typedef struct rr_pool_unit_header rr_pool_unit_header_s;
typedef struct rr_pool rr_pool_s;
struct rr_pool_unit_header
{
rr_pool_unit_header_s *next;
};
struct rr_pool
{
usz_t capacity;
usz_t item_size;
rr_pool_unit_header_s *first_free;
void *allocation;
rr_generic_allocator_s *allocator;
};
rr_generic_pool_s rr_new_dynamic_pool(rr_generic_allocator_s *allocator, usz_t unit_size, usz_t capacity);
rr_generic_pool_s rr_new_static_pool(rr_generic_allocator_s *allocator, usz_t unit_size, usz_t capacity);
void rr_destruct_pool(rr_generic_pool_s *pool);
void * rr_pool_alloc_slot(rr_generic_pool_s *pool);
void rr_pool_free_slot(rr_generic_pool_s *pool, void *block);
#endif // RR_POOL_PROVIDER_H