Created
August 24, 2017 06:52
-
-
Save luyao795/82190b84bf6a8abd139cb2680435e207 to your computer and use it in GitHub Desktop.
Header file for Fixed Size Allocator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef FIXEDSIZEALLOCATOR_H | |
#define FIXEDSIZEALLOCATOR_H | |
#include "BitArray.h" | |
namespace Engine | |
{ | |
class FixedSizeAllocator | |
{ | |
public: | |
FixedSizeAllocator(const size_t size, const size_t numBlocks, BlockAllocator* blockAllocator); | |
void destroy(); | |
void* allocate(size_t size); | |
void free(void* pointer); | |
bool isInRange(void* pointer, const void* left, const void* right); | |
size_t getBlockIndex(void* pointer); | |
size_t getBlockSize() const; | |
size_t getBlockNumber() const; | |
void* getBlockStart() const; | |
void* getBlockOver() const; | |
BitArray* getBitArray(); | |
private: | |
~FixedSizeAllocator(); | |
BitArray* bitArray; | |
size_t blockSize; | |
size_t numBlock; | |
static BlockAllocator* allocator; | |
void* blockStart; | |
}; | |
} | |
#endif // !FIXEDSIZEALLOCATOR_H |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment