2018-05-10 22:10:35 +01:00
|
|
|
#pragma once
|
|
|
|
|
2018-05-13 15:29:15 +01:00
|
|
|
#if defined (__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2018-05-10 22:10:35 +01:00
|
|
|
#include "CustomAssert.h"
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
typedef struct PoolAllocator
|
|
|
|
{
|
2020-06-08 18:54:57 +01:00
|
|
|
void* buf; //preallocated buffer
|
|
|
|
void* nextFreeBlock;
|
2018-05-10 22:10:35 +01:00
|
|
|
unsigned blockSize;
|
|
|
|
unsigned size; //size is exact multiple of block size
|
|
|
|
} PoolAllocator;
|
|
|
|
|
2020-06-08 18:54:57 +01:00
|
|
|
PoolAllocator createPoolAllocator(void* b, unsigned bs, unsigned s);
|
2018-08-26 14:11:43 +01:00
|
|
|
void destroyPoolAllocator(PoolAllocator* pa);
|
|
|
|
void* poolAllocate(PoolAllocator* pa);
|
|
|
|
void poolFree(PoolAllocator* pa, void* p);
|
2018-05-13 15:29:15 +01:00
|
|
|
|
|
|
|
#if defined (__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|