DelegateMQ
Loading...
Searching...
No Matches
Allocator Class Reference

#include <Allocator.h>

Inheritance diagram for Allocator:
AllocatorPool< T, Objects >

Public Member Functions

 Allocator (size_t size, uint32_t objects=0, char *memory=NULL, const char *name=NULL)
 
 ~Allocator ()
 Destructor.
 
void * Allocate (size_t size)
 
void Deallocate (void *pBlock)
 
const char * GetName ()
 
size_t GetBlockSize ()
 
uint32_t GetBlockCount ()
 
uint32_t GetBlocksInUse ()
 
uint32_t GetAllocations ()
 
uint32_t GetDeallocations ()
 

Detailed Description

See also
https://github.com/endurodave/Allocator David Lafreniere

Constructor & Destructor Documentation

◆ Allocator()

Allocator::Allocator ( size_t size,
uint32_t objects = 0,
char * memory = NULL,
const char * name = NULL )

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 NULL to obtain memory from global heap. If not NULL, the objects argument defines the size of the memory block (size x objects = memory size in bytes).
[in]name- optional allocator name string.

◆ ~Allocator()

Allocator::~Allocator ( )

Destructor.

Member Function Documentation

◆ 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 NULL 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()

uint32_t Allocator::GetAllocations ( )
inline

Gets the total number of allocations for this allocator instance.

Returns
The total number of allocations.

◆ GetBlockCount()

uint32_t Allocator::GetBlockCount ( )
inline

Gets the maximum number of blocks created by the allocator.

Returns
The number of fixed memory blocks created.

◆ GetBlocksInUse()

uint32_t 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()

uint32_t 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 NULL if none was assigned.

The documentation for this class was generated from the following files: