Files
sdk/tests/ffi/regress_b_261224444_test.dart
Daco Harkes 546ddc645e [ffi] Format tests with Dart 3.8
Change-Id: Iaa29e2df68875fbb363ab2ac5cd59cc99e65532b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/422102
Auto-Submit: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Bob Nystrom <rnystrom@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
Commit-Queue: Daco Harkes <dacoharkes@google.com>
2025-04-11 07:52:19 -07:00

26 lines
721 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.
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);
}