Class Allocator
Defined in File blockAllocator.h
Page Contents
Nested Relationships
Nested Types
Inheritance Relationships
Derived Type
public AllocatorPool< T, Objects >(Template Class AllocatorPool)
Class Documentation
-
class Allocator
Inheritence diagram for Allocator:
![digraph {
graph [bgcolor="#00000000"]
node [shape=rectangle style=filled fillcolor="#FFFFFF" font=Helvetica padding=2]
edge [color="#1414CE"]
"2" [label="AllocatorPool< T, Objects >" tooltip="AllocatorPool< T, Objects >"]
"1" [label="Allocator" tooltip="Allocator" fillcolor="#BFBFBF"]
"2" -> "1" [dir=forward tooltip="public-inheritance"]
}](../_images/graphviz-15550f6abd1de3b9705e1ae7466dd5d26b748782.png)
See http://www.codeproject.com/Articles/1083210/An-efficient-Cplusplus-fixed-block-memory-allocato
Subclassed by AllocatorPool< T, Objects >
Public Types
Public Functions
-
Allocator(size_t size, size_t objects = 0, char *memory = nullptr, const char *name = nullptr)
Constructor
- Parameters
size – [in] - size of the fixed blocks
objects – [in] - maximum number of object. If 0, new blocks are created off the heap as necessary.
memory – [in] - pointer to a block of static memory for allocator or nullptr to obtain memory from global heap. If not nullptr, the objects argument defines the size of the memory block (size x objects = memory size in bytes).
name – [in] - optional allocator name string.
-
~Allocator()
Destructor.
-
void *Allocate(size_t size)
Get a pointer to a memory block.
- Parameters
size – [in] - size of the block to allocate
- Returns
Returns pointer to the block. Otherwise nullptr if unsuccessful.
-
void Deallocate(void *pBlock)
Return a pointer to the memory pool.
- Parameters
pBlock – [in] - block of memory deallocate (i.e push onto free-list)
-
inline const char *GetName() const
Get the allocator name string.
- Returns
A pointer to the allocator name or nullptr if none was assigned.
-
inline size_t GetBlockSize() const
Gets the fixed block memory size, in bytes, handled by the allocator.
- Returns
The fixed block size in bytes.
-
inline size_t GetBlockCount() const
Gets the maximum number of blocks created by the allocator.
- Returns
The number of fixed memory blocks created.
-
inline size_t GetBlocksInUse() const
Gets the number of blocks in use.
- Returns
The number of blocks in use by the application.
-
inline size_t GetAllocations() const
Gets the total number of allocations for this allocator instance.
- Returns
The total number of allocations.
-
inline size_t GetDeallocations() const
Gets the total number of deallocations for this allocator instance.
- Returns
The total number of deallocations.
-
inline AllocatorMode GetMode() const
-
Allocator(size_t size, size_t objects = 0, char *memory = nullptr, const char *name = nullptr)