class GroupAllocator

Inherits: INonCopyable

Provides an easy way to group multiple allocations under a single (actual) allocation.

Requires the user to first call Reserve() methods for all requested data elements, followed by Initialize(), after which allocation/deallocation can follow using Allocate/Free methods.

Public

Constructors

GroupAllocator

GroupAllocator() = default

GroupAllocator

GroupAllocator(GroupAllocator &&other) noexcept

Methods

~GroupAllocator

~GroupAllocator() noexcept

Initialize

void Initialize()

Allocates internal memory as reserved by previous calls to Reserve().

Must be called before any calls to Allocate.

Reserve

GroupAllocator &Reserve(u32 amount)

Reserves the specified amount of bytes to allocate.

Multiple calls to Reserve() are cumulative. After all needed memory is reserved, call Initialize(), followed by actual allocation via Allocate().

Allocate

u8 *Allocate(u32 amount)

Allocates a new piece of memory of the specified size.

amount
Amount of memory to allocate, in bytes.

Free

void Free(void *data)

Deallocates a previously allocated piece of memory.

Clear

void Clear()

Frees any internally allocated buffers.

Operators

operator=

GroupAllocator &operator=(GroupAllocator &&other) noexcept

Private

Fields

mBuffer

u8 * mBuffer

mNextAllocation

u8 * mNextAllocation

mByteCount

u32 mByteCount