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