#include <Corrade/Containers/GrowableArray.h>
template<class T>
ArrayMallocAllocator struct new in 2020.06
Malloc-based allocator for growable arrays.
An ArrayAllocator that allocates and deallocates memory using the C std::
All reallocation operations expect that T
is trivially copyable. If it's not, use ArrayNewAllocator instead.
Compared to ArrayNewAllocator, this allocator stores array capacity in bytes and, together with the fact that std::
Public types
-
enum (anonymous): std::
size_t { AllocationOffset = Implementation::AllocatorTraits<T>::Offset } - using Type = T
Public static functions
-
static auto allocate(std::
size_t capacity) -> T* - Allocate an array of given capacity.
-
static void reallocate(T*& array,
std::
size_t prevSize, std:: size_t newCapacity) - Reallocate an array to given capacity.
- static void deallocate(T* data)
- Deallocate an array.
-
static auto grow(T* array,
std::
size_t desired) -> std:: size_t - Grow an array.
-
static auto capacity(T* array) -> std::
size_t - Array capacity.
- static auto base(T* array) -> void*
- Array base address.
-
static void deleter(T* data,
std::
size_t size) - Array deleter.
Enum documentation
template<class T>
enum Corrade:: Containers:: ArrayMallocAllocator<T>:: (anonymous): std:: size_t
Enumerators | |
---|---|
AllocationOffset |
Offset at the beginning of the allocation to store allocation capacity. At least as large as std:: |
Typedef documentation
template<class T>
typedef T Corrade:: Containers:: ArrayMallocAllocator<T>:: Type
Pointer type
Function documentation
template<class T>
static T* Corrade:: Containers:: ArrayMallocAllocator<T>:: allocate(std:: size_t capacity)
Allocate an array of given capacity.
std::char
array with an extra space to store capacity
before the front, returning it cast to T*
. The allocation is guaranteed to follow T
allocation requirements up to the platform default allocation alignment.
template<class T>
static void Corrade:: Containers:: ArrayMallocAllocator<T>:: reallocate(T*& array,
std:: size_t prevSize,
std:: size_t newCapacity)
Reallocate an array to given capacity.
Calls std::array
(offset by the space to store capacity) and then updates the stored capacity to newCapacity
and the array
reference to point to the new (offset) location, in case the reallocation wasn't done in-place. The prevSize
parameter is ignored, as std::T
allocation requirements up to the platform default allocation alignment.
template<class T>
static void Corrade:: Containers:: ArrayMallocAllocator<T>:: deallocate(T* data)
Deallocate an array.
Calls std::
template<class T>
static std:: size_t Corrade:: Containers:: ArrayMallocAllocator<T>:: grow(T* array,
std:: size_t desired)
Grow an array.
Behaves the same as ArrayNewAllocator::
template<class T>
static std:: size_t Corrade:: Containers:: ArrayMallocAllocator<T>:: capacity(T* array)
Array capacity.
Retrieves the capacity that's stored before the front of the array
.
template<class T>
static void* Corrade:: Containers:: ArrayMallocAllocator<T>:: base(T* array)
Array base address.
Returns the address with AllocationOffset subtracted.
template<class T>
static void Corrade:: Containers:: ArrayMallocAllocator<T>:: deleter(T* data,
std:: size_t size)
Array deleter.
Since the types have trivial destructors, directly delegates into deallocate(). The size
parameter is unused.