Customizable functions to allocate, reallocate and deallocate memory. More...
#include <Memory.h>
Classes | |
| struct | Statistics |
| Holds Statistics about how many allocations/release have been issued. More... | |
Public Member Functions | |
| template<typename T , typename... U> | |
| T * | create (U &&... u) |
Allocate and construct an object of type T using this allocator. | |
| void * | allocate (const void *owner, size_t numBytes, size_t alignment) |
| Allocates numBytes bytes of memory. | |
| void * | reallocate (void *memory, size_t numBytes) |
| Change size of already allocated memory block. | |
| void | release (void *memory) |
| Free memory allocated by MemoryAllocator::allocate and / or reallocated by MemoryAllocator::reallocate. | |
| virtual void * | allocateImpl (const void *owner, size_t numBytes, size_t alignment)=0 |
| Allocate virtual function to be reimplemented. | |
| virtual void * | reallocateImpl (void *memory, size_t numBytes)=0 |
| Re-allocate virtual function to be reimplemented. | |
| virtual void | releaseImpl (void *memory)=0 |
| Release virtual function to be reimplemented. | |
Public Attributes | |
| Statistics | statistics |
| Holds statistics about how many allocations/release have been issued. | |
Customizable functions to allocate, reallocate and deallocate memory.
|
inline |
Allocates numBytes bytes of memory.
| owner | Memory address of the object that "owns" this allocation. |
| numBytes | Number of bytes to allocate |
| alignment | Alignment of the allocated block of memory |
|
pure virtual |
Allocate virtual function to be reimplemented.
| owner | Can be nullptr or an address belonging to a previous allocation of this allocator |
| numBytes | How many bytes to allocate |
| alignment | Alignment of the allocation |
false if the passed not-null owner doesn't belong to this allocator or the allocation itself fails Implemented in SC::FixedAllocator, and SC::VirtualAllocator.
|
inline |
Allocate and construct an object of type T using this allocator.
|
inline |
Change size of already allocated memory block.
Existing contents of input buffer will be copied over.
| memory | pointer to memory previously allocated by Memory::allocate or Memory::Reallocate |
| numBytes | new size of the reallocated block |
|
pure virtual |
Re-allocate virtual function to be reimplemented.
Implemented in SC::FixedAllocator, and SC::VirtualAllocator.
|
inline |
Free memory allocated by MemoryAllocator::allocate and / or reallocated by MemoryAllocator::reallocate.
| memory | Memory to release / deallocate |
|
pure virtual |
Release virtual function to be reimplemented.
Implemented in SC::FixedAllocator.
| Statistics SC::MemoryAllocator::statistics |
Holds statistics about how many allocations/release have been issued.