ReactPhysics3D  v0.10.2
C++ Physics engine library
Loading...
Searching...
No Matches
reactphysics3d::MemoryAllocator Class Referenceabstract

Abstract class with the basic interface of all the derived memory allocators. More...

#include <include/reactphysics3d/memory/MemoryAllocator.h>

Inheritance diagram for reactphysics3d::MemoryAllocator:
reactphysics3d::DefaultAllocator reactphysics3d::HeapAllocator reactphysics3d::PoolAllocator reactphysics3d::SingleFrameAllocator

Public Member Functions

 MemoryAllocator ()=default
 Constructor.
 
virtual ~MemoryAllocator ()=default
 Destructor.
 
MemoryAllocatoroperator= (MemoryAllocator &allocator)=default
 Assignment operator.
 
virtual void * allocate (size_t size)=0
 Allocate memory of a given size (in bytes) and return a pointer to the allocated memory.
 
virtual void release (void *pointer, size_t size)=0
 Release previously allocated memory.
 

Static Public Member Functions

static void * alignAddress (void *pointer, uint8 alignment)
 Given a pointer to memory, this method returns the next aligned address.
 
static void * alignAddress (void *pointer, uint8 alignment, ptrdiff_t &alignmentOffset)
 Given a pointer to memory, this method returns the next aligned address and also output the alignment offset.
 

Detailed Description

Abstract class with the basic interface of all the derived memory allocators.

Member Function Documentation

◆ alignAddress() [1/2]

void * MemoryAllocator::alignAddress ( void *  pointer,
uint8  alignment 
)
static

Given a pointer to memory, this method returns the next aligned address.

Parameters
pointerPointer to a memory location
alignmentDesired alignment
Returns
Pointer to the next aligned memory location

◆ alignAddress() [2/2]

void * MemoryAllocator::alignAddress ( void *  pointer,
uint8  alignment,
ptrdiff_t &  outAlignmentOffset 
)
static

Given a pointer to memory, this method returns the next aligned address and also output the alignment offset.

Parameters
pointerPointer to a memory location
alignmentDesired alignment
outAlignmentOffsetOutput alignment offset needed to align the initial pointer
Returns
Pointer to the next aligned memory location

◆ allocate()

virtual void * reactphysics3d::MemoryAllocator::allocate ( size_t  size)
pure virtual

Allocate memory of a given size (in bytes) and return a pointer to the allocated memory.

The return allocated memory must be 16 bytes aligned.

Implemented in reactphysics3d::DefaultAllocator, reactphysics3d::HeapAllocator, reactphysics3d::PoolAllocator, and reactphysics3d::SingleFrameAllocator.

◆ release()

virtual void reactphysics3d::MemoryAllocator::release ( void *  pointer,
size_t  size 
)
pure virtual

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