![]() |
XII Release 0.1.0
|
#include <Allocator.h>
Classes | |
| struct | Stats |
Public Member Functions | |
| xiiAllocator () | |
| Copyright (c) Theophilus Eriata. All Rights Reserved. | |
| virtual void * | Allocate (size_t uiSize, size_t uiAlign, xiiMemoryUtils::DestructorFunction destructorFunc=nullptr)=0 |
| virtual void | Deallocate (void *pPtr)=0 |
| virtual void * | Reallocate (void *pPtr, size_t uiCurrentSize, size_t uiNewSize, size_t uiAlign) |
| Copyright (c) Theophilus Eriata. All Rights Reserved. | |
| virtual size_t | AllocatedSize (const void *pPtr)=0 |
| virtual xiiAllocatorId | GetId () const =0 |
| virtual Stats | GetStats () const =0 |
Base class for all memory allocators.
This abstract base class defines the interface for all allocators in xiiEngine. Allocators are responsible for memory management and can implement different allocation strategies (heap, linear, frame, etc.).
Key concepts:
Usage:
|
pure virtual |
Interface, do not use this directly, always use the new/delete macros below
Allocates aligned memory of the specified size. The destructorFunc parameter is used for automatic cleanup when the allocator is reset or destroyed (mainly used by linear allocators).
Implemented in xiiInternal::xiiAllocatorImpl< AllocationPolicy, TrackingMode >, xiiInternal::xiiAllocatorImpl< xiiAllocationPolicyHeap, TrackingMode >, xiiInternal::xiiAllocatorImpl< xiiAllocationPolicyLinear< false >, TrackingMode >, xiiInternal::xiiAllocatorImpl< xiiAllocationPolicyProxy, TrackingMode >, xiiLinearAllocator< TrackingMode, OverwriteMemoryOnReset >, xiiLinearAllocator< xiiAllocatorTrackingMode::Basics, OverwriteMemoryOnReset >, and xiiLinearAllocator< xiiAllocatorTrackingMode::DoNotTrack >.
|
pure virtual |
Returns the number of bytes allocated at this address.
This information is only available if allocation tracking is enabled (see xiiAllocatorTrackingMode and XII_ALLOC_TRACKING_DEFAULT). Returns 0 when tracking is disabled or for invalid pointers. Primarily used for debugging and memory analysis.
Implemented in xiiInternal::xiiAllocatorImpl< AllocationPolicy, TrackingMode >, xiiInternal::xiiAllocatorImpl< xiiAllocationPolicyHeap, TrackingMode >, xiiInternal::xiiAllocatorImpl< xiiAllocationPolicyLinear< false >, TrackingMode >, and xiiInternal::xiiAllocatorImpl< xiiAllocationPolicyProxy, TrackingMode >.
|
pure virtual |
Deallocates memory previously allocated by this allocator.
The pointer must have been returned by a previous call to Allocate() on this allocator instance. Passing nullptr is safe and will be ignored.
Implemented in xiiInternal::xiiAllocatorImpl< AllocationPolicy, TrackingMode >, xiiInternal::xiiAllocatorImpl< xiiAllocationPolicyHeap, TrackingMode >, xiiInternal::xiiAllocatorImpl< xiiAllocationPolicyLinear< false >, TrackingMode >, xiiInternal::xiiAllocatorImpl< xiiAllocationPolicyProxy, TrackingMode >, xiiLinearAllocator< TrackingMode, OverwriteMemoryOnReset >, xiiLinearAllocator< xiiAllocatorTrackingMode::Basics, OverwriteMemoryOnReset >, and xiiLinearAllocator< xiiAllocatorTrackingMode::DoNotTrack >.
|
virtual |
Copyright (c) Theophilus Eriata. All Rights Reserved.
Reallocates memory, potentially moving the data to a new location.
Default implementation allocates new memory, copies old data, and deallocates the old memory. Some allocators may provide more efficient implementations.
Reimplemented in xiiInternal::xiiAllocatorMixinReallocate< AllocationPolicy, TrackingMode, true >.