2018-05-20 16:09:41 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#if defined (__cplusplus)
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "CustomAssert.h"
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
typedef struct ConsecutivePoolAllocator
|
|
|
|
{
|
|
|
|
char* buf; //preallocated buffer
|
|
|
|
uint32_t* nextFreeBlock;
|
|
|
|
unsigned blockSize;
|
|
|
|
unsigned size; //size is exact multiple of block size
|
|
|
|
} ConsecutivePoolAllocator;
|
|
|
|
|
2018-08-26 15:11:43 +02:00
|
|
|
ConsecutivePoolAllocator createConsecutivePoolAllocator(char* b, unsigned bs, unsigned s);
|
|
|
|
void destroyConsecutivePoolAllocator(ConsecutivePoolAllocator* pa);
|
|
|
|
void* consecutivePoolAllocate(ConsecutivePoolAllocator* pa, uint32_t numBlocks);
|
|
|
|
void consecutivePoolFree(ConsecutivePoolAllocator* pa, void* p, uint32_t numBlocks);
|
|
|
|
void* consecutivePoolReAllocate(ConsecutivePoolAllocator* pa, void* currentMem, uint32_t currNumBlocks);
|
2018-05-20 16:09:41 +02:00
|
|
|
|
|
|
|
#if defined (__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|