ReactPhysics3D: reactphysics3d::MemoryAllocator Class Reference

| ReactPhysics3D v0.10.2 C++ Physics engine library

Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
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:

## Public Member Functions
| MemoryAllocator ()=default
| Constructor.
virtual | ~MemoryAllocator ()=default
| Destructor.
MemoryAllocator & | operator= (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

  pointer | Pointer to a memory location
  alignment | Desired 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

  pointer | Pointer to a memory location
  alignment | Desired alignment
  outAlignmentOffset | Output 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

Release previously allocated memory.

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

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

- include/reactphysics3d/memory/MemoryAllocator.h
- src/memory/MemoryAllocator.cpp