62 const unsigned char& numBlocks) {
67 _pData_ =
new unsigned char[blockSize * numBlocks];
80 for (
unsigned char indexBlock = 0; indexBlock != numBlocks; p += blockSize)
114 const std::size_t& blockSize) {
116 GUM_ASSERT(pDeallocatedBlock >=
_pData_);
119 unsigned char* toRelease =
static_cast< unsigned char*
>(pDeallocatedBlock);
122 GUM_ASSERT((toRelease -
_pData_) % blockSize == 0);
151 const unsigned char& numBlocks) {
163 for (_Chunks_::iterator chunkIter =
_chunks_.begin(); chunkIter !=
_chunks_.end(); ++chunkIter)
164 chunkIter->_release_();
179 for (_Chunks_::iterator chunksIter =
_chunks_.begin();; ++chunksIter) {
191 if (chunksIter->_blocksAvailable_ > 0) {
209 std::ptrdiff_t offset = 0;
void deallocate(void *pDeallocatedBlock)
Deallocates a block.
FixedAllocator(const std::size_t &blockSize, const unsigned char &numBlocks=UCHAR_MAX)
Constructor.
_Chunks_::iterator _deallocChunk_
Last Chunk used for a deallocation.
unsigned char _numBlocks_
The maximum number of blocks a chunk can allocate.
std::size_t _blockSize_
Size of a memory block allocated.
~FixedAllocator()
Destructor.
_Chunks_::iterator _allocChunk_
Last Chunk used for an allocation.
void * allocate()
Allocates a block.
Headers of gum::FixedAllocator.
gum is the global namespace for all aGrUM entities
Allocates objects of one given size.
void * _allocate_(const std::size_t &blockSize)
Allocates a block of memory.
unsigned char _firstAvailableBlock_
Holds the index of the first block available in this chunck.
void _deallocat_(void *p, const std::size_t &blockSize)
Deallocates a block of memory.
unsigned char * _pData_
Pointer to the managed memory itself.
void _init_(const std::size_t &blockSize, const unsigned char &numBlocks)
Initializes a Chunk object.
void _release_()
Releases the allocated memory.
unsigned char _blocksAvailable_
Number of blocks available in this chunck.