Spec-Zone.ru › Dart 2

dart:ffi

Метод allocate<T extends NativeType>

Pointer<T> allocate<T extends NativeType>(
  1. int byteCount,
  2. {int? alignment}
)

Выделяет byteCount байт памяти в куче нативной платформы.

Если alignment указано, выделенная память будет выровнена как минимум по alignment байтам.

Чтобы выделить кратное число sizeOf<T>() байт, вызовите функцию-аллокатор напрямую: allocator<T>(count) (см. AllocatorAlloc.call для подробностей).

// This allocates two bytes. If you intended two Int32's, this is an
// error.
allocator.allocate<Int32>(2);

// This allocates eight bytes, which is enough space for two Int32's.
// However, this is not the idiomatic way.
allocator.allocate<Int32>(sizeOf<Int32>() * 2);

// The idiomatic way to allocate space for two Int32 is to call the
// allocator directly as a function.
allocator<Int32>(2);

Выбрасывает ArgumentError, если количество байт или выравнивание не могут быть удовлетворены.

Реализация

Pointer<T> allocate<T extends NativeType>(int byteCount, {int? alignment});

© 2012 the Dart project authors
Licensed under the BSD 3-Clause "New" or "Revised" License.
https://api.dart.dev/stable/2.18.5/dart-ffi/Allocator/allocate.html

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API