create static method
Creates a DynamicAlignedArray
instance with the specified parameters.
initialCapacity
: The initial capacity of the array.elementSize
: The size of each element in the array.alignment
: The alignment requirement for the array. Returns a pointer to the allocatedDynamicAlignedArray
instance.
Implementation
static Pointer<DynamicAlignedArray> create({
int initialCapacity = 16,
int elementSize = 4,
int alignment = 4,
}) {
final ptr = calloc<DynamicAlignedArray>();
ptr.ref
..length = 0
..capacity = initialCapacity
..elementSize = elementSize
..alignment = alignment;
// Allocate aligned memory for data
ptr.ref.data = calloc
.allocAligned<DynamicAlignedArray>(
elementSize * initialCapacity,
alignment,
)
.cast();
return ptr;
}