Skip to content

AllocatorAlloc

extension AllocatorAlloc on Allocator

Annotations: @Since.new('2.12')

Extension on Allocator to provide allocation with NativeType.

Methods

call() extension

Pointer<T> call<T extends SizedNativeType>([int count = 1])

Allocates sizeOf<T>() * count bytes of memory using allocate.

dart
// This allocates eight bytes, which is enough space for two Int32's.
allocator<Int32>(2);

This extension method must be invoked with a compile-time constant T.

To allocate a specific number of bytes, not just a multiple of sizeOf<T>(), use allocate. To allocate with a non constant T, use allocate. Prefer call for normal use, and use allocate for implementing an Allocator in terms of other allocators.

Available on Allocator, provided by the AllocatorAlloc extension

Implementation
dart
external Pointer<T> call<T extends SizedNativeType>([int count = 1]);