Allocators Tools Initial
This commit is contained in:
parent
4a2ab6f5d0
commit
6d0a4676ab
34 changed files with 3847 additions and 0 deletions
42
Allocators/outdated/inc/PoolAllocator.hpp
Normal file
42
Allocators/outdated/inc/PoolAllocator.hpp
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
#pragma once
|
||||
|
||||
#include "ChunkAllocator.hpp"
|
||||
|
||||
namespace tp {
|
||||
|
||||
// Pool Allocator
|
||||
// Overcomes chunk allocator fixed number of max allocations
|
||||
struct PoolAlloc {
|
||||
|
||||
PoolAlloc(ualni aBlockSize, ualni aChunkSize);
|
||||
void* allocate();
|
||||
void deallocate(void* aPtr);
|
||||
~PoolAlloc();
|
||||
|
||||
private:
|
||||
|
||||
struct Chunk : public ChunkAlloc {
|
||||
Chunk(ualni aBlockSize, ualni aChunlSize) : ChunkAlloc(aBlockSize, aChunlSize) {}
|
||||
Chunk* mNext = NULL;
|
||||
Chunk* mPrev = NULL;
|
||||
};
|
||||
|
||||
struct Chunks {
|
||||
void add(Chunk*);
|
||||
void remove(Chunk*);
|
||||
Chunk* find(void* aPtr);
|
||||
Chunk* findNotFull();
|
||||
Chunk** mBuff = NULL;
|
||||
ualni mUsedLen = 0;
|
||||
ualni mLen = 0;
|
||||
|
||||
private:
|
||||
Chunk** findUtil(Chunk** aLeft, Chunk** aRight, void* aPtr);
|
||||
};
|
||||
|
||||
Chunks mChunks;
|
||||
Chunk* mFreeChunk = NULL;
|
||||
ualni mBlockSize;
|
||||
ualni mChunkSize;
|
||||
};
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue