copyUint32ListFromOwnedFfiPtr function

Uint32List? copyUint32ListFromOwnedFfiPtr(
  1. Pointer<Uint8> data,
  2. int length
)

From an owned pointer allocated in native code, copy the data into the Dart VM Heap as a Uint32List and then immediately free the owned ffi pointer.

Implementation

Uint32List? copyUint32ListFromOwnedFfiPtr(
  Pointer<Uint8> data,
  int length,
) {
  if (data == nullptr || length == 0) {
    return null;
  }

  final Uint32List out =
      Uint32List.fromList(data.cast<Int8>().asTypedList(length));
  malloc.free(data);
  return out;
}