PALISADE Lattice Crypto Library  1.11.9
A lattice crypto library for software engineers by software engineers.
Classes | Public Member Functions | List of all members
Allocator Class Reference

#include <blockAllocator.h>

Inheritance diagram for Allocator:
Inheritance graph
[legend]

Public Member Functions

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

Detailed Description

See http://www.codeproject.com/Articles/1083210/An-efficient-Cplusplus-fixed-block-memory-allocato

Constructor & Destructor Documentation

◆ 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.

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 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: