Class Allocator

Inheritance Relationships

Derived Types

Class Documentation

class Allocator

Base class for an Allocator.

Subclassed by Azura::Memory::MonotonicAllocator, Azura::Memory::RangeAllocator

Public Functions

Allocator(void *resource, U32 size)
Allocator(AddressPtr resource, U32 size)
~Allocator()
Allocator(const Allocator &other)
Allocator &operator=(const Allocator &other)
Allocator(Allocator &&other)
Allocator &operator=(Allocator &&other)
template <typename Type, typename... Args>
UniquePtr<Type> New(Args... args)

Allocates & initializes the Type and returns a pointer to that memory location.

New is analogous to the C++ new keyword. It tells the allocator to construct an object in the memory recourse it is managing. This functions first allocates a block of memory and then constructs it with the supplied params. Some example usages:

auto floatDataPtr = MyAllocator.New<float>(0.0f);

class CustomClass{};
auto customDataPtr = MyAllocator.New<CustomClass>();

The actual returned type is a UniquePtr<T> which is a std::unique_ptr with a custom deleter.

Return
A unique pointer with a custom deleter
Template Parameters
  • Type: Data Type to allocate
  • Args: Initialization Arguments
Parameters
  • args: The list of arguments that Type needs for construction

template <typename Type, typename... Args>
UniqueArrayPtr<Type> NewArray(U32 numElements, Args... args)
template <typename Type, typename... Args>
UniquePtr<Type> RawNew(Args... args)
template <typename Type, typename... Args>
UniqueArrayPtr<Type> RawNewArray(U32 numElements, Args... args)

Protected Functions

U32 Size() const
AddressPtr BasePtr() const
virtual void *Allocate(U32 size, U32 alignment) = 0
virtual void Deallocate(void *address) = 0
void Reset()