Mark3 Realtime Kernel
Mark3::AutoAlloc Class Reference

The AutoAlloc class. This class provides an object-allocation interface for both kernel objects and user-defined types. This class supplies callouts for alloc/free that use object-type metadata to determine how objects may be allocated, allowing a user to create custom dynamic memory implementations for specific object types and sizes. As a result, the user-defined allocators can avoid the kinds of memory fragmentation and exhaustion issues that occur in typical embedded systems in which a single heap is used to satisfy all allocations in the application. More...

#include <autoalloc.h>

Static Public Member Functions

static void Init (void)
 Init Initialize the AutoAllocator before use. Called by Kernel::Init(). More...
 
static void SetAllocatorFunctions (AutoAllocAllocator_t pfAllocator_, AutoAllocFree_t pfFree_)
 SetAllocatorFunctions Set the functions used by this class to allocate/free memory used in the kernel. More...
 
template<typename T , AutoAllocType e>
static T * NewObject ()
 
template<typename T , AutoAllocType e>
static void DestroyObject (T *pObj_)
 
static void * NewUserTypeAllocation (uint8_t eUserType_)
 NewUserTypeAllocation Attempt to allocate a user-defined object type from the heap. More...
 
static void DestroyUserTypeAllocation (uint8_t eUserType_, void *pvObj_)
 DestroyUserTypeAllocation Free a previously allocated user-defined object. More...
 
static void * NewRawData (size_t sSize_)
 NewRawData Attempt to allocate a blob of raw data from the heap. More...
 
static void DestroyRawData (void *pvData_)
 DestroyRawData Free a previously allocated blob of data allocated via NewRawData() More...
 

Static Private Member Functions

static void * Allocate (AutoAllocType eType_, size_t sSize_)
 
static void Free (AutoAllocType eType_, void *pvObj_)
 

Static Private Attributes

static AutoAllocAllocator_t m_pfAllocator
 Function used to allocate objects. More...
 
static AutoAllocFree_t m_pfFree
 Funciton used to free objectss. More...
 

Detailed Description

The AutoAlloc class. This class provides an object-allocation interface for both kernel objects and user-defined types. This class supplies callouts for alloc/free that use object-type metadata to determine how objects may be allocated, allowing a user to create custom dynamic memory implementations for specific object types and sizes. As a result, the user-defined allocators can avoid the kinds of memory fragmentation and exhaustion issues that occur in typical embedded systems in which a single heap is used to satisfy all allocations in the application.

Definition at line 72 of file autoalloc.h.

Member Function Documentation

◆ Allocate()

void * Mark3::AutoAlloc::Allocate ( AutoAllocType  eType_,
size_t  sSize_ 
)
staticprivate

Definition at line 58 of file autoalloc.cpp.

◆ DestroyObject()

template<typename T , AutoAllocType e>
static void Mark3::AutoAlloc::DestroyObject ( T *  pObj_)
inlinestatic

Template function used to manage the destruction and de-allocation of predefined kernel objects

Definition at line 106 of file autoalloc.h.

◆ DestroyRawData()

void Mark3::AutoAlloc::DestroyRawData ( void *  pvData_)
static

DestroyRawData Free a previously allocated blob of data allocated via NewRawData()

Parameters
pvData_pointer to previously-created data object

Definition at line 105 of file autoalloc.cpp.

◆ DestroyUserTypeAllocation()

void Mark3::AutoAlloc::DestroyUserTypeAllocation ( uint8_t  eUserType_,
void *  pvObj_ 
)
static

DestroyUserTypeAllocation Free a previously allocated user-defined object.

Parameters
pvObj_Pointer to previously-allocated object, allocated through NewUserTypeAllocation ()
eUserType_User defined object type, interpreted by the allocator function

Definition at line 95 of file autoalloc.cpp.

◆ Free()

void Mark3::AutoAlloc::Free ( AutoAllocType  eType_,
void *  pvObj_ 
)
staticprivate

Definition at line 67 of file autoalloc.cpp.

◆ Init()

void Mark3::AutoAlloc::Init ( void  )
static

Init Initialize the AutoAllocator before use. Called by Kernel::Init().

Definition at line 83 of file autoalloc.cpp.

◆ NewObject()

template<typename T , AutoAllocType e>
static T* Mark3::AutoAlloc::NewObject ( )
inlinestatic

Template function used to manage the allocation of predefined kernel object types

Definition at line 93 of file autoalloc.h.

◆ NewRawData()

void * Mark3::AutoAlloc::NewRawData ( size_t  sSize_)
static

NewRawData Attempt to allocate a blob of raw data from the heap.

Parameters
sSize_Size of the data blob (in bytes)
Returns
pointer to newly-allocated blob of data, or nullptr on error.

Definition at line 100 of file autoalloc.cpp.

◆ NewUserTypeAllocation()

void * Mark3::AutoAlloc::NewUserTypeAllocation ( uint8_t  eUserType_)
static

NewUserTypeAllocation Attempt to allocate a user-defined object type from the heap.

Parameters
eUserType_User defined object type, interpreted by the allocator function
Returns
pointer to a newly-created object, or nullptr on error.

Definition at line 90 of file autoalloc.cpp.

◆ SetAllocatorFunctions()

void Mark3::AutoAlloc::SetAllocatorFunctions ( AutoAllocAllocator_t  pfAllocator_,
AutoAllocFree_t  pfFree_ 
)
static

SetAllocatorFunctions Set the functions used by this class to allocate/free memory used in the kernel.

Parameters
pfAllocator_Function to allocate an object based on its type and/or size
pfFree_Function to free a previously-allocated object

Definition at line 76 of file autoalloc.cpp.

Member Data Documentation

◆ m_pfAllocator

AutoAllocAllocator_t Mark3::AutoAlloc::m_pfAllocator
staticprivate

Function used to allocate objects.

Definition at line 147 of file autoalloc.h.

◆ m_pfFree

AutoAllocFree_t Mark3::AutoAlloc::m_pfFree
staticprivate

Funciton used to free objectss.

Funciton used to free objects.

Definition at line 148 of file autoalloc.h.


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