![]() |
aGrUM
0.16.0
|
Allocates objects of one given size. More...
#include <agrum/core/fixedAllocator.h>
Public Member Functions | |
const size_t & | objectSize () |
Returns the size of block allocated by this FixedAllocator. More... | |
Constructors / Destructors | |
FixedAllocator (const std::size_t &blockSize, const unsigned char &numBlocks=UCHAR_MAX) | |
Constructor. More... | |
~FixedAllocator () | |
Destructor. More... | |
Allocator / Deallocator | |
void * | allocate () |
Allocates a block. More... | |
void | deallocate (void *pDeallocatedBlock) |
Deallocates a block. More... | |
Classes | |
struct | __Chunk |
Allocates objects of one given size. More... | |
Allocates objects of one given size.
Fixed allocator knows how to allocate and deallocate blocks of fixed size but is not limited to a chunck size. Its capacity is limited only by the available memory. To achieve this, FixedAllocator aggregates a vector of Chunk objects. Whenever an allocation request occurs, FixedAllocators looks for a Chunk that can accomodate the request. If all Chunks are filled up, FixedAllocator appends a new Chunk.
Definition at line 58 of file fixedAllocator.h.
|
private |
Vector of __Chunk objects.
Definition at line 178 of file fixedAllocator.h.
INLINE gum::FixedAllocator::FixedAllocator | ( | const std::size_t & | blockSize, |
const unsigned char & | numBlocks = UCHAR_MAX |
||
) |
Constructor.
blockSize | is the size of an allocated block. |
numBlocks | is the number of block allocated per chunk numBlock * blockSize is the size that a chunk allocates directly when it is created |
Definition at line 130 of file fixedAllocator_inl.h.
References __allocChunk, __blockSize, __chunks, __deallocChunk, and __numBlocks.
INLINE gum::FixedAllocator::~FixedAllocator | ( | ) |
INLINE void * gum::FixedAllocator::allocate | ( | ) |
Allocates a block.
Definition at line 157 of file fixedAllocator_inl.h.
References __allocChunk, __blockSize, __chunks, __deallocChunk, gum::FixedAllocator::__Chunk::__init(), and __numBlocks.
INLINE void gum::FixedAllocator::deallocate | ( | void * | pDeallocatedBlock | ) |
Deallocates a block.
Definition at line 186 of file fixedAllocator_inl.h.
References __blockSize, __chunks, __deallocChunk, __numBlocks, and gum::FixedAllocator::__Chunk::__pData.
|
inline |
Returns the size of block allocated by this FixedAllocator.
Definition at line 162 of file fixedAllocator.h.
References __blockSize.
|
private |
Last Chunk used for an allocation.
Definition at line 184 of file fixedAllocator.h.
Referenced by allocate(), and FixedAllocator().
|
private |
Size of a memory block allocated.
Definition at line 168 of file fixedAllocator.h.
Referenced by allocate(), deallocate(), FixedAllocator(), and objectSize().
|
private |
Definition at line 179 of file fixedAllocator.h.
Referenced by allocate(), deallocate(), FixedAllocator(), and ~FixedAllocator().
|
private |
Last Chunk used for a deallocation.
Definition at line 189 of file fixedAllocator.h.
Referenced by allocate(), deallocate(), and FixedAllocator().
|
private |
The maximum number of blocks a chunk can allocate.
Definition at line 173 of file fixedAllocator.h.
Referenced by allocate(), deallocate(), and FixedAllocator().