Techneck/code/source-c/chunk_pool.h

36 lines
944 B
C
Raw Normal View History

2023-10-17 11:25:02 +00:00
#ifndef TC_CHUNK_POOL_H
#define TC_CHUNK_POOL_H
#include <utility/utility.h>
#include <chunk.h>
typedef struct tc_chunk_pool tc_chunk_pool_s;
typedef struct tc_chunk_pool_entry tc_chunk_pool_entry_s;
struct tc_chunk_pool_entry
{
tc_chunk_pool_entry_s *next;
tc_chunk_pool_entry_s *previous;
tc_chunk_s chunk;
};
struct tc_chunk_pool
{
u32_t capacity;
u32_t used_entries;
tc_chunk_pool_entry_s *entries;
tc_chunk_pool_entry_s *first_free;
tc_chunk_pool_s *continuation;
};
void tc_cleanup_chunk_pool ();
void tc_init_chunk_pool (u32_t capacity);
tc_chunk_s * tc_allocate_chunk ();
void tc_deallocate_chunk (tc_chunk_s *chunk);
#endif // TC_CHUNK_POOL_H