mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:00:09 +00:00
[test/ffi] Free pointer allocated via malloc
Closes: https://github.com/dart-lang/sdk/issues/50705 Change-Id: I96d0bdf5e7fe95b8841d9c7ba3db8e785574222e Cq-Include-Trybots: luci.dart.try:vm-kernel-asan-linux-release-x64-try,vm-kernel-precomp-asan-linux-release-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275260 Reviewed-by: Tess Strickland <sstrickl@google.com> Commit-Queue: Daco Harkes <dacoharkes@google.com>
This commit is contained in:
parent
fd6fa010ec
commit
c3fce2f559
|
@ -8,12 +8,18 @@ import 'ffi_test_helpers.dart';
|
|||
|
||||
main() {
|
||||
// Ensure we have FfiTrampolineData in heap.
|
||||
final foo = DynamicLibrary.process()
|
||||
final malloc = DynamicLibrary.process()
|
||||
.lookup<NativeFunction<Pointer<Void> Function(IntPtr)>>("malloc")
|
||||
.asFunction<Pointer<Void> Function(int)>();
|
||||
print(foo);
|
||||
print(malloc);
|
||||
|
||||
triggerGc();
|
||||
|
||||
print(foo(100).address);
|
||||
final pointer = malloc(100);
|
||||
|
||||
print(pointer.address);
|
||||
|
||||
final free = DynamicLibrary.process()
|
||||
.lookupFunction<Void Function(Pointer), void Function(Pointer)>('free');
|
||||
free(pointer);
|
||||
}
|
||||
|
|
|
@ -10,12 +10,18 @@ import 'ffi_test_helpers.dart';
|
|||
|
||||
main() {
|
||||
// Ensure we have FfiTrampolineData in heap.
|
||||
final foo = DynamicLibrary.process()
|
||||
final malloc = DynamicLibrary.process()
|
||||
.lookup<NativeFunction<Pointer<Void> Function(IntPtr)>>("malloc")
|
||||
.asFunction<Pointer<Void> Function(int)>();
|
||||
print(foo);
|
||||
print(malloc);
|
||||
|
||||
triggerGc();
|
||||
|
||||
print(foo(100).address);
|
||||
final pointer = malloc(100);
|
||||
|
||||
print(pointer.address);
|
||||
|
||||
final free = DynamicLibrary.process()
|
||||
.lookupFunction<Void Function(Pointer), void Function(Pointer)>('free');
|
||||
free(pointer);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue