#include <arrayallocator.h>
Array allocator which only allocates and frees entries of SIZE bytes. Depending on the type of array the allocation might relocate already existing items.
| SIZE | The size of an entry in bytes. |
| ARRAY | Array to be used as allocator |
Classes | |
| struct | FreeEntry |
Public Member Functions | |
| ArrayAllocator () | |
| ArrayAllocator (ArrayAllocator &&src) | |
| Int | ComputeArraySize (Int currentSize, Int increment, Int minChunkSize) |
| void * | Alloc (Int64 s, MAXON_SOURCE_LOCATION_DECLARATION) |
| void * | Realloc (void *, Int64, MAXON_SOURCE_LOCATION_DECLARATION) |
| template<typename T > | |
| void | Free (T *&p) |
| Bool | IsCompatibleWithDefaultAllocator (void *p) const |
| ARRAY & | GetArray () |
| const ARRAY & | GetArray () const |
Private Attributes | |
| Int | _usedEntryCnt |
| FreeEntry * | _freeEntry |
| ARRAY | _buffer |
| ArrayAllocator | ( | ) |
Default Constructor.
| ArrayAllocator | ( | ArrayAllocator< SIZE, ARRAY > && | src | ) |
Move constructor.
Computes the new size 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. |
| void* Alloc | ( | Int64 | s, |
| MAXON_SOURCE_LOCATION_DECLARATION | |||
| ) |
Allocates a memory block. 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. |
| void* Realloc | ( | void * | , |
| Int64 | , | ||
| MAXON_SOURCE_LOCATION_DECLARATION | |||
| ) |
Not supported for this allocator.
| void Free | ( | T *& | p | ) |
Frees a memory block.
| [in,out] | p | Memory block address (can be nullptr, will be nullptr after return) |
| Bool IsCompatibleWithDefaultAllocator | ( | void * | p | ) | const |
Returns if a memory block allocated via this allocator can be reallocated or freed by the DefaultAllocator.
| [in] | p | Memory block address. |
| ARRAY& GetArray | ( | ) |
| const ARRAY& GetArray | ( | ) | const |
|
private |
|
private |
|
private |