40 const unsigned char& numBlocks) {
45 __pData =
new unsigned char[blockSize * numBlocks];
58 for (
unsigned char indexBlock = 0; indexBlock != numBlocks; p += blockSize)
92 const std::size_t& blockSize) {
94 GUM_ASSERT(pDeallocatedBlock >=
__pData);
97 unsigned char* toRelease =
static_cast< unsigned char*
>(pDeallocatedBlock);
100 GUM_ASSERT((toRelease -
__pData) % blockSize == 0);
108 static_cast< unsigned char >((toRelease -
__pData) / blockSize);
131 const unsigned char& numBlocks) {
143 for (__Chunks::iterator chunkIter =
__chunks.begin();
146 chunkIter->__release();
161 for (__Chunks::iterator chunksIter =
__chunks.begin();; ++chunksIter) {
173 if (chunksIter->__blocksAvailable > 0) {
192 std::ptrdiff_t offset = 0;
void * allocate()
Allocates a block.
void deallocate(void *pDeallocatedBlock)
Deallocates a block.
unsigned char __blocksAvailable
Number of blocks available in this chunck.
FixedAllocator(const std::size_t &blockSize, const unsigned char &numBlocks=UCHAR_MAX)
Constructor.
__Chunks::iterator __allocChunk
Last Chunk used for an allocation.
Allocates objects of one given size.
void __deallocat(void *p, const std::size_t &blockSize)
Deallocates a block of memory.
std::size_t __blockSize
Size of a memory block allocated.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
unsigned char __numBlocks
The maximum number of blocks a chunk can allocate.
void * __allocate(const std::size_t &blockSize)
Allocates a block of memory.
unsigned char * __pData
Pointer to the managed memory itself.
__Chunks::iterator __deallocChunk
Last Chunk used for a deallocation.
unsigned char __firstAvailableBlock
Holds the index of the first block available in this chunck.
~FixedAllocator()
Destructor.
void __init(const std::size_t &blockSize, const unsigned char &numBlocks)
Initializes a Chunk object.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void __release()
Releases the allocated memory.