#include <customallocator.h>
Custom allocator/memory pool interface.
Public Member Functions | |
| MAXON_ADD_TO_REFERENCE_CLASS (Int ComputeArraySize(Int currentSize, Int increment, Int minChunkSize) { return DefaultAllocator::ComputeArraySize(currentSize, increment, minChunkSize);}) | |
| MAXON_METHOD void * | Alloc (Int s, MAXON_SOURCE_LOCATION_DECLARATION) |
| MAXON_METHOD void * | AllocClear (Int s, MAXON_SOURCE_LOCATION_DECLARATION) |
| MAXON_METHOD void * | Realloc (void *data, Int size, MAXON_SOURCE_LOCATION_DECLARATION) |
| MAXON_ADD_TO_REFERENCE_CLASS (template< typename T > void Free(T *&p) { if(this->GetPointer()) this->GetPointer() ->PrivateFree(static_cast< void * >(p));p=nullptr;}) | |
| MAXON_ADD_TO_REFERENCE_CLASS (Bool IsCompatibleWithDefaultAllocator(void *) const { return false;}) | |
| MAXON_METHOD void * | PrivateAlloc (Int size, Bool clear, MAXON_SOURCE_LOCATION_DECLARATION) |
| MAXON_METHOD void | PrivateFree (void *data) |
| MAXON_METHOD Int | PrivateGetDataSize (void *data) |
Static Public Member Functions | |
| static MAXON_METHOD CustomAllocatorInterface * | Alloc (MAXON_SOURCE_LOCATION_DECLARATION) |
Private Member Functions | |
| MAXON_INTERFACE_NONVIRTUAL (CustomAllocatorInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.customallocator", MAXON_IMPLEMENTATION_MODULE("net.maxon.kernel")) | |
|
private |
|
static |
| [in] | allocLocation | Source location. |
| MAXON_ADD_TO_REFERENCE_CLASS | ( | Int ComputeArraySize(Int currentSize, Int increment, Int minChunkSize) { return DefaultAllocator::ComputeArraySize(currentSize, increment, minChunkSize);} | ) |
Computes the new capacity for a growing array. THREADSAFE.
| [in] | currentSize | Current number of elements. |
| [in] | increment | Number of elements to be added (>= 1) |
| [in] | minChunkSize | The minimum number of elements upon array creation. |
| MAXON_METHOD void* Alloc | ( | Int | s, |
| MAXON_SOURCE_LOCATION_DECLARATION | |||
| ) |
Allocates a memory block. THREADSAFE. The memory is not cleared, it may contain a certain byte pattern in debug mode.
| [in] | s | Block size in bytes (values < 0 will return nullptr) |
| [in] | allocLocation | Pass MAXON_SOURCE_LOCATION(_NAME) to add the current source line and file. |
| MAXON_METHOD void* AllocClear | ( | Int | s, |
| MAXON_SOURCE_LOCATION_DECLARATION | |||
| ) |
Allocates a memory block and clears it. THREADSAFE.
| [in] | s | Block size in bytes (values < 0 will return nullptr) |
| [in] | allocLocation | Pass MAXON_SOURCE_LOCATION(_NAME) to add the current source line and file. |
| MAXON_METHOD void* Realloc | ( | void * | data, |
| Int | size, | ||
| MAXON_SOURCE_LOCATION_DECLARATION | |||
| ) |
Resizes an allocated memory block. If allocation of a new block fails the old one won't be freed.
| [in] | data | Data location, can be nullptr. |
| [in] | size | Minimum new data size (values < 0 will return nullptr). |
| [in] | allocLocation | Structure with caller data like source file and source line. |
| MAXON_ADD_TO_REFERENCE_CLASS | ( | template< typename T > void Free(T *&p) { if(this->GetPointer()) this->GetPointer() ->PrivateFree(static_cast< void * >(p));p=nullptr;} | ) |
| MAXON_ADD_TO_REFERENCE_CLASS | ( | Bool IsCompatibleWithDefaultAllocator(void *) const { return false;} | ) |
Returns if a memory block allocated via this allocator can be reallocated or freed by the DefaultAllocator.
| MAXON_METHOD void* PrivateAlloc | ( | Int | size, |
| Bool | clear, | ||
| MAXON_SOURCE_LOCATION_DECLARATION | |||
| ) |
Allocates a block of memory.
| [in] | size | Minimum data size (values < 0 will return nullptr). |
| [in] | clear | If the data should be cleared this must be true. |
| [in] | allocLocation | Structure with caller data like source file and source line. |
| MAXON_METHOD void PrivateFree | ( | void * | data | ) |
Frees a memory block (might have been allocated by a different local Allocator of the same type).
| [in] | data | Pointer as returned by Alloc, guaranteed to be valid and not nullptr. |
| MAXON_METHOD Int PrivateGetDataSize | ( | void * | data | ) |
Returns the maximum size of an allocated block (might be bigger than what was acutally allocated).
| [in] | data | Pointer as returned by Alloc, guaranteed to be valid and != nullptr. |