diff --git a/runtime/tests/vm/dart/isolates/dart_api_create_lightweight_isolate_test.dart b/runtime/tests/vm/dart/isolates/dart_api_create_lightweight_isolate_test.dart index f2e8a709bece..25e0199eb00e 100644 --- a/runtime/tests/vm/dart/isolates/dart_api_create_lightweight_isolate_test.dart +++ b/runtime/tests/vm/dart/isolates/dart_api_create_lightweight_isolate_test.dart @@ -14,6 +14,7 @@ import 'dart:isolate'; import 'package:expect/expect.dart'; import 'package:ffi/ffi.dart'; +import '../../../../../tests/ffi/calloc.dart'; import '../../../../../tests/ffi/dylib_utils.dart'; final bool isAOT = Platform.executable.contains('dart_precompiled_runtime'); @@ -62,7 +63,7 @@ abstract class FfiBindings { Expect.isTrue(isolate.address != 0); return isolate; } finally { - free(cname); + calloc.free(cname); } } @@ -86,8 +87,8 @@ abstract class FfiBindings { onError != null ? onError.nativePort : 0, onExit != null ? onExit.nativePort : 0); - free(libraryUri); - free(functionName); + calloc.free(libraryUri); + calloc.free(functionName); } } @@ -120,7 +121,7 @@ Future withPeerPointer(fun(Pointer peer)) async { // wait a little here to ensure the write of the callback has arrived. await Future.delayed(const Duration(milliseconds: 100)); Expect.equals('xbz', Utf8.fromUtf8(peer.cast())); - free(peer); + calloc.free(peer); } } diff --git a/runtime/tests/vm/dart/regress_41971_test.dart b/runtime/tests/vm/dart/regress_41971_test.dart index 28f63ad1d5e9..7979d0d1e592 100644 --- a/runtime/tests/vm/dart/regress_41971_test.dart +++ b/runtime/tests/vm/dart/regress_41971_test.dart @@ -11,6 +11,8 @@ import 'dart:ffi'; import 'package:expect/expect.dart'; import 'package:ffi/ffi.dart'; +import '../../../../tests/ffi/calloc.dart'; + class X { int field; X(this.field); @@ -35,8 +37,8 @@ int loadFrom(Pointer p) { } void main() { - final p = allocate(count: 128); + final p = calloc(128); p[0] = 42; Expect.equals(42, loadFrom(p)); - free(p); + calloc.free(p); } diff --git a/runtime/tests/vm/dart/thread_priority_macos_test.dart b/runtime/tests/vm/dart/thread_priority_macos_test.dart index b7c8280362f5..473c1ce267c0 100644 --- a/runtime/tests/vm/dart/thread_priority_macos_test.dart +++ b/runtime/tests/vm/dart/thread_priority_macos_test.dart @@ -10,6 +10,8 @@ import 'dart:io'; import 'package:expect/expect.dart'; import 'package:ffi/ffi.dart'; +import '../../../../tests/ffi/calloc.dart'; + // pthread_t pthread_self() typedef PthreadSelfFT = int Function(); typedef PthreadSelfNFT = IntPtr Function(); @@ -34,11 +36,11 @@ class SchedParam extends Struct { main(args) { if (Platform.isMacOS) { - final policy = allocate(count: 1); - final param = allocate(count: 1); + final policy = calloc(1); + final param = calloc(1); Expect.equals(0, pthreadGetSchedParam(pthreadSelf(), policy, param)); Expect.equals(15, param.ref.schedPriority); - free(policy); - free(param); + calloc.free(policy); + calloc.free(param); } } diff --git a/runtime/tests/vm/dart_2/isolates/dart_api_create_lightweight_isolate_test.dart b/runtime/tests/vm/dart_2/isolates/dart_api_create_lightweight_isolate_test.dart index 0daead0f8fbe..d35474e27f2b 100644 --- a/runtime/tests/vm/dart_2/isolates/dart_api_create_lightweight_isolate_test.dart +++ b/runtime/tests/vm/dart_2/isolates/dart_api_create_lightweight_isolate_test.dart @@ -14,6 +14,7 @@ import 'dart:isolate'; import 'package:expect/expect.dart'; import 'package:ffi/ffi.dart'; +import '../../../../../tests/ffi/calloc.dart'; import '../../../../../tests/ffi/dylib_utils.dart'; final bool isAOT = Platform.executable.contains('dart_precompiled_runtime'); @@ -62,7 +63,7 @@ abstract class FfiBindings { Expect.isTrue(isolate.address != 0); return isolate; } finally { - free(cname); + calloc.free(cname); } } @@ -86,8 +87,8 @@ abstract class FfiBindings { onError != null ? onError.nativePort : 0, onExit != null ? onExit.nativePort : 0); - free(libraryUri); - free(functionName); + calloc.free(libraryUri); + calloc.free(functionName); } } @@ -120,7 +121,7 @@ Future withPeerPointer(fun(Pointer peer)) async { // wait a little here to ensure the write of the callback has arrived. await Future.delayed(const Duration(milliseconds: 100)); Expect.equals('xbz', Utf8.fromUtf8(peer.cast())); - free(peer); + calloc.free(peer); } } diff --git a/runtime/tests/vm/dart_2/regress_41971_test.dart b/runtime/tests/vm/dart_2/regress_41971_test.dart index 28f63ad1d5e9..7979d0d1e592 100644 --- a/runtime/tests/vm/dart_2/regress_41971_test.dart +++ b/runtime/tests/vm/dart_2/regress_41971_test.dart @@ -11,6 +11,8 @@ import 'dart:ffi'; import 'package:expect/expect.dart'; import 'package:ffi/ffi.dart'; +import '../../../../tests/ffi/calloc.dart'; + class X { int field; X(this.field); @@ -35,8 +37,8 @@ int loadFrom(Pointer p) { } void main() { - final p = allocate(count: 128); + final p = calloc(128); p[0] = 42; Expect.equals(42, loadFrom(p)); - free(p); + calloc.free(p); } diff --git a/runtime/tests/vm/dart_2/thread_priority_macos_test.dart b/runtime/tests/vm/dart_2/thread_priority_macos_test.dart index b466eb0f26fa..fdce726a3629 100644 --- a/runtime/tests/vm/dart_2/thread_priority_macos_test.dart +++ b/runtime/tests/vm/dart_2/thread_priority_macos_test.dart @@ -10,6 +10,8 @@ import 'dart:io'; import 'package:expect/expect.dart'; import 'package:ffi/ffi.dart'; +import '../../../../tests/ffi/calloc.dart'; + // pthread_t pthread_self() typedef PthreadSelfFT = int Function(); typedef PthreadSelfNFT = IntPtr Function(); @@ -34,11 +36,11 @@ class SchedParam extends Struct { main(args) { if (Platform.isMacOS) { - final policy = allocate(count: 1); - final param = allocate(count: 1); + final policy = calloc(1); + final param = calloc(1); Expect.equals(0, pthreadGetSchedParam(pthreadSelf(), policy, param)); Expect.equals(15, param.ref.schedPriority); - free(policy); - free(param); + calloc.free(policy); + calloc.free(param); } }