|
Cogs.Foundation
|
Base allocator implementation. More...
#include <Allocator.h>
Public Member Functions | |
| Allocator ()=default | |
| virtual | ~Allocator ()=default |
| virtual void * | allocate (size_t size, size_t alignment=0, MemBlockType type=MemBlockType::Block) |
| Allocate raw memory. | |
| virtual void | deallocate (void *ptr, size_t size, MemBlockType type=MemBlockType::Block) |
| Deallocate the memory block at the given pointer, with the given size. | |
| virtual void | changeType (void *ptr, size_t size, MemBlockType oldType, MemBlockType newType) |
| virtual size_t | getAllocatedBytes () const |
| Return the number of bytes currently allocated by this allocator. | |
| virtual size_t | getAllocationCount () const |
| Return the number of allocations currently allocated by this allocator. | |
Static Public Member Functions | |
| static Allocator * | defaultAllocator () |
| Gets the system default allocator. | |
| static Allocator * | overflowAllocator () |
Protected Attributes | |
| Cogs::Atomic< size_t > | allocated {0} |
| Cogs::Atomic< size_t > | allocations {0} |
Base allocator implementation.
Allocates raw, uninitialized heap memory.
|
default |
|
virtualdefault |
|
virtual |
Allocate raw memory.
| size | Size in bytes of requested allocation. |
| alignment | Alignment in bytes. |
References Cogs::Memory::kDefaultAlignment, LOG_ERROR, and Cogs::logger.
Referenced by Cogs::Memory::StdAllocator< T >::allocate(), Cogs::Memory::create(), Cogs::Collections::SmallVectorImplBase< T, isPod >::grow(), and Cogs::Collections::SmallVectorBase::growPod().
|
virtual |
|
virtual |
Deallocate the memory block at the given pointer, with the given size.
The size parameter may be given to enable extra checking when releasing memory.
| ptr | Pointer to previously allocated memory. |
| size | Size in bytes of the given allocation. |
Referenced by Cogs::Memory::StdAllocator< T >::deallocate(), Cogs::Memory::destroy(), Cogs::Collections::SmallVectorBase::growPod(), and Cogs::Collections::SmallVectorImpl< T >::release().
|
static |
Gets the system default allocator.
|
inlinevirtual |
Return the number of bytes currently allocated by this allocator.
|
inlinevirtual |
Return the number of allocations currently allocated by this allocator.
|
static |
Gets the system default overflow allocator, used by collections that may overflow a custom given allocator.
|
protected |
|
protected |