#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. |
ARRAYSELECTOR | Selector for array type to be used as allocator |
FLUSH | Use true if Flush() shall be called on the array instead of Reset() when all entries have been freed. |
Classes | |
struct | FreeEntry |
Public Types | |
using | ValueType = ArrayAllocatorValueType< SIZE > |
using | ArrayType = typename ARRAYSELECTOR::template Type< ValueType > |
using | IsArrayAllocator = std::true_type |
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 |
ArrayType & | GetArray () |
const ArrayType & | GetArray () const |
template<typename T > | |
Bool | DeleteAll () |
Private Attributes | |
Int | _usedEntryCnt |
FreeEntry * | _freeEntry |
ArrayType | _buffer |
using ValueType = ArrayAllocatorValueType<SIZE> |
using IsArrayAllocator = std::true_type |
ArrayAllocator | ( | ) |
Default Constructor.
ArrayAllocator | ( | ArrayAllocator< SIZE, ARRAYSELECTOR, FLUSH > && | 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. |
ArrayType& GetArray | ( | ) |
const ArrayType& GetArray | ( | ) | const |
Bool DeleteAll | ( | ) |
|
private |
|
private |
|
private |