mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 08:20:31 +00:00
c3fce2f559
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>
27 lines
735 B
Dart
27 lines
735 B
Dart
// Copyright (c) 2022, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// @dart=2.9
|
|
|
|
import 'dart:ffi';
|
|
|
|
import 'ffi_test_helpers.dart';
|
|
|
|
main() {
|
|
// Ensure we have FfiTrampolineData in heap.
|
|
final malloc = DynamicLibrary.process()
|
|
.lookup<NativeFunction<Pointer<Void> Function(IntPtr)>>("malloc")
|
|
.asFunction<Pointer<Void> Function(int)>();
|
|
print(malloc);
|
|
|
|
triggerGc();
|
|
|
|
final pointer = malloc(100);
|
|
|
|
print(pointer.address);
|
|
|
|
final free = DynamicLibrary.process()
|
|
.lookupFunction<Void Function(Pointer), void Function(Pointer)>('free');
|
|
free(pointer);
|
|
}
|