Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
Burger::AllocatorBase Struct Referenceabstract

Base class for memory manager objects. More...

Inheritance diagram for Burger::AllocatorBase:
Inheritance graph
[legend]
Collaboration diagram for Burger::AllocatorBase:
Collaboration graph
[legend]

Public Member Functions

const Burger::StaticRTTIget_StaticRTTI (void) const noexcept override
 Get the description to the class.
 
 AllocatorBase () noexcept=default
 Default constructor.
 
virtual void * alloc (uintptr_t uSize) const noexcept=0
 Allocate memory.
 
virtual void free (const void *pInput) const noexcept=0
 Release memory.
 
virtual void * realloc (const void *pInput, uintptr_t uSize) const noexcept=0
 Reallocate memory.
 
void * alloc_clear (uintptr_t uSize) const noexcept
 Allocate memory that is preinitialized to zero.
 
void * alloc_copy (const void *pInput, uintptr_t uSize) const noexcept
 Allocate a buffer and copy data into it.
 
- Public Member Functions inherited from Burger::Base
const char * get_class_name (void) const noexcept
 Get the name of the class.
 
virtual ~Base () noexcept=default
 Destructor.
 

Static Public Attributes

static const Burger::StaticRTTI g_StaticRTTI
 The global description of the class.
 
- Static Public Attributes inherited from Burger::Base
static const Burger::StaticRTTI g_StaticRTTI
 The global description of the class.
 

Detailed Description

Base class for memory manager objects.


To allow functions that allocate memory to use arbitrary memory allocation systems, this class instance is passed so functionality could be redirected to any memory allocated needed.

Since this is defined as a base class, it's not meant to be created directly. Derive from this class to implement a custom memory handler, or use the predefined AllocatorANSI or AllocatorHandle classes.

See also
AllocatorANSI or AllocatorHandle

Constructor & Destructor Documentation

◆ AllocatorBase()

Burger::AllocatorBase::AllocatorBase ( )
defaultnoexcept

Default constructor.


Member Function Documentation

◆ alloc()

void * Burger::AllocatorBase::alloc ( uintptr_t uSize) const
pure virtualnoexcept

Allocate memory.


Allocate memory. If the function fails, return nullptr

Parameters
uSizeNumber of bytes to allocate
Returns
Pointer to valid memory or nullptr on error or no memory requested.
See also
free() or alloc_clear()

Implemented in Burger::AllocatorANSI, and Burger::AllocatorHandle.

◆ alloc_clear()

void *BURGER_API Burger::AllocatorBase::alloc_clear ( uintptr_t uSize) const
noexcept

Allocate memory that is preinitialized to zero.


Allocate memory using the call alloc(). If the allocation was successful, initialize all the memory to zero.

Parameters
uSizeNumber of bytes requested to allocate
Returns
nullptr if no bytes are requested or if an out of memory condition exists.
See also
alloc() or free()

◆ alloc_copy()

void *BURGER_API Burger::AllocatorBase::alloc_copy ( const void * pInput,
uintptr_t uSize ) const
noexcept

Allocate a buffer and copy data into it.


Allocate memory and copy the contents of the pointer to the new memory

Parameters
pInputPointer to the data to copy. nullptr will leave the data uninitialized
uSizeSize of the buffer to allocate.
Returns
nullptr on failure, a pointer with the data on success
See also
alloc(), or realloc()

◆ free()

void Burger::AllocatorBase::free ( const void * pInput) const
pure virtualnoexcept

Release memory.


If nullptr is passed, do nothing. Otherwise, release the memory.

Parameters
pInputPointer to memory to release, or nullptr.
See also
alloc() or realloc()

Implemented in Burger::AllocatorANSI, and Burger::AllocatorHandle.

◆ get_StaticRTTI()

const Burger::StaticRTTI * Burger::AllocatorBase::get_StaticRTTI ( void ) const
overridevirtualnoexcept

Get the description to the class.


This virtual function will pull the pointer to the StaticRTTI instance that has the name of the class. Due to it being virtual, it will be the name of the most derived class.

Returns
Pointer to a global, read only instance of StaticRTTI for the true class

Reimplemented from Burger::Base.

Reimplemented in Burger::AllocatorHandle.

◆ realloc()

Burger::AllocatorBase::realloc ( const void * pInput,
uintptr_t uSize ) const
pure virtualnoexcept

Reallocate memory.


Call the virtual function to reallocate memory. If the function fails, the memory in pInput is left intact and nullptr is returned. If uSize is zero, pInput is freed and nullptr is returned.

Note
If nullptr is returned, assume the memory point is still valid, and dispose of it if it is not needed. Otherwise memory can leak.
Parameters
pInputPointer to memory to read from and release
uSizeNumber of bytes to allocate
Returns
Pointer to valid memory or nullptr on error or no memory requested.
See also
alloc() or free()

Implemented in Burger::AllocatorANSI, and Burger::AllocatorHandle.

Member Data Documentation

◆ g_StaticRTTI

const Burger::StaticRTTI Burger::AllocatorBase::g_StaticRTTI
static

The global description of the class.


This record contains the name of this class and a reference to the parent