#include <blockAllocator.h>
◆ Allocator()
Allocator::Allocator |
( |
size_t |
size, |
|
|
usint |
objects = 0 , |
|
|
char * |
memory = nullptr , |
|
|
const char * |
name = nullptr |
|
) |
| |
Constructor
- Parameters
-
[in] | size | - size of the fixed blocks |
[in] | objects | - maximum number of object. If 0, new blocks are created off the heap as necessary. |
[in] | memory | - 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). |
[in] | name | - optional allocator name string. |
◆ Allocate()
void * Allocator::Allocate |
( |
size_t |
size | ) |
|
Get a pointer to a memory block.
- Parameters
-
[in] | size | - size of the block to allocate |
- Returns
- Returns pointer to the block. Otherwise nullptr if unsuccessful.
◆ Deallocate()
void Allocator::Deallocate |
( |
void * |
pBlock | ) |
|
Return a pointer to the memory pool.
- Parameters
-
[in] | pBlock | - block of memory deallocate (i.e push onto free-list) |
◆ GetAllocations()
usint Allocator::GetAllocations |
( |
| ) |
|
|
inline |
Gets the total number of allocations for this allocator instance.
- Returns
- The total number of allocations.
◆ GetBlockCount()
usint Allocator::GetBlockCount |
( |
| ) |
|
|
inline |
Gets the maximum number of blocks created by the allocator.
- Returns
- The number of fixed memory blocks created.
◆ GetBlocksInUse()
usint Allocator::GetBlocksInUse |
( |
| ) |
|
|
inline |
Gets the number of blocks in use.
- Returns
- The number of blocks in use by the application.
◆ GetBlockSize()
size_t Allocator::GetBlockSize |
( |
| ) |
|
|
inline |
Gets the fixed block memory size, in bytes, handled by the allocator.
- Returns
- The fixed block size in bytes.
◆ GetDeallocations()
usint Allocator::GetDeallocations |
( |
| ) |
|
|
inline |
Gets the total number of deallocations for this allocator instance.
- Returns
- The total number of deallocations.
◆ GetName()
const char* Allocator::GetName |
( |
| ) |
|
|
inline |
Get the allocator name string.
- Returns
- A pointer to the allocator name or nullptr if none was assigned.
The documentation for this class was generated from the following files:
- src/core/include/utils/blockAllocator/blockAllocator.h
- src/core/lib/utils/blockAllocator/blockAllocator.cpp