[vm/ffi] Introduce a Pointer<T extends Struct>.refWithFinalizer(finalizer, token)
#56796
Labels
Pointer<T extends Struct>.refWithFinalizer(finalizer, token)
#56796
It's quite common to want to return a struct from Dart code using
dart:ffi
and having a call with the pointer inside that code (dart-lang/native#1601, dart-lang/native#1480 (comment)).That currently requires the following dance:
calloc
aPointer<MyStruct>
cast
the struct to<Uint8>
asTypedList
withcalloc.nativeFree
as finalizerStruct.create<MyStruct>
with the typed dataMaybe we could simplify step 2 to 4 by introducing:
The text was updated successfully, but these errors were encountered: