mirror of
https://github.com/hiddify/hiddify-next.git
synced 2026-06-11 21:01:33 +08:00
13 lines
264 B
Dart
13 lines
264 B
Dart
import 'dart:ffi';
|
|
|
|
import 'package:ffi/ffi.dart';
|
|
|
|
R withMemory<R, T extends NativeType>(int size, R Function(Pointer<T> memory) action) {
|
|
final memory = calloc<Int8>(size);
|
|
try {
|
|
return action(memory.cast());
|
|
} finally {
|
|
calloc.free(memory);
|
|
}
|
|
}
|