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
|
|
|
|
{
|
2020-06-08 19:54:57 +02:00
|
|
|
void* buf; //preallocated buffer
|
|
|
|
void* nextFreeBlock;
|
2018-05-20 16:09:41 +02:00
|
|
|
unsigned blockSize;
|
|
|
|
unsigned size; //size is exact multiple of block size
|
2020-05-29 22:49:16 +02:00
|
|
|
unsigned numFreeBlocks;
|
2018-05-20 16:09:41 +02:00
|
|
|
} ConsecutivePoolAllocator;
|
|
|
|
|
2020-06-08 19:54:57 +02:00
|
|
|
ConsecutivePoolAllocator createConsecutivePoolAllocator(void* b, unsigned bs, unsigned s);
|
2018-08-26 15:11:43 +02:00
|
|
|
void destroyConsecutivePoolAllocator(ConsecutivePoolAllocator* pa);
|
2020-05-16 14:17:03 +02:00
|
|
|
uint32_t consecutivePoolAllocate(ConsecutivePoolAllocator* pa, uint32_t numBlocks);
|
2018-08-26 15:11:43 +02:00
|
|
|
void consecutivePoolFree(ConsecutivePoolAllocator* pa, void* p, uint32_t numBlocks);
|
2020-06-11 22:37:50 +02:00
|
|
|
uint32_t consecutivePoolReAllocate(ConsecutivePoolAllocator* pa, void* currentMem, uint32_t currNumBlocks, uint32_t newNumBlocks);
|
2020-03-05 22:18:26 +01:00
|
|
|
void CPAdebugPrint(ConsecutivePoolAllocator* pa);
|
2020-05-16 14:17:03 +02:00
|
|
|
void* getCPAptrFromOffset(ConsecutivePoolAllocator* pa, uint32_t offset);
|
2018-05-20 16:09:41 +02:00
|
|
|
|
|
|
|
#if defined (__cplusplus)
|
|
|
|
}
|
|
|
|
#endif
|