Cogs.Core
|
Base allocator implementation. More...
#include <Allocator.h>
Public Member Functions | |
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.
Definition at line 29 of file Allocator.h.
|
virtual |
Allocate raw memory.
size | Size in bytes of requested allocation. |
alignment | Alignment in bytes. |
Reimplemented in Cogs::ResourceAllocator, Cogs::Core::CoreAllocator, and Cogs::Core::TextureAllocator.
Definition at line 29 of file Allocator.cpp.
Referenced by Cogs::Core::CoreAllocator::allocate(), and Cogs::Core::TextureAllocator::allocate().
|
virtual |
Definition at line 72 of file Allocator.cpp.
|
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. |
Reimplemented in Cogs::Core::TextureAllocator, Cogs::ResourceAllocator, and Cogs::Core::CoreAllocator.
Definition at line 58 of file Allocator.cpp.
Referenced by Cogs::Core::TextureAllocator::deallocate(), and Cogs::Core::CoreAllocator::deallocate().
|
static |
Gets the system default allocator.
Definition at line 17 of file Allocator.cpp.
Referenced by Cogs::Factory::createDevice().
|
inlinevirtual |
Return the number of bytes currently allocated by this allocator.
Reimplemented in Cogs::Core::CoreAllocator.
Definition at line 65 of file Allocator.h.
|
inlinevirtual |
Return the number of allocations currently allocated by this allocator.
Reimplemented in Cogs::Core::CoreAllocator.
Definition at line 68 of file Allocator.h.
|
static |
Gets the system default overflow allocator, used by collections that may overflow a custom given allocator.
Definition at line 24 of file Allocator.cpp.
|
protected |
Definition at line 71 of file Allocator.h.
|
protected |
Definition at line 72 of file Allocator.h.