dart-sdk/tests/ffi_2/regress_flutter97301_test.dart
Alexander Markov 3d977bc191 [vm/test] Fix memory leak in ffi/regress_flutter97301_test
TEST=ci
Fixes https://github.com/dart-lang/sdk/issues/48283

Change-Id: I22d9ebac3240e9ca84fec833340d71b58d01119d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/231335
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Siva Annamalai <asiva@google.com>
Commit-Queue: Siva Annamalai <asiva@google.com>
2022-02-03 00:28:55 +00:00

25 lines
696 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.
//
// Verifies that there are no deoptimizing IntConverter instructions
// used when converting Pointer to TypedData.
// Regression test for https://github.com/flutter/flutter/issues/97301.
// @dart = 2.9
import "dart:ffi";
import "package:ffi/ffi.dart";
@pragma("vm:never-inline")
Pointer<Uint32> foo() => calloc(4);
main() {
final Pointer<Uint32> offsetsPtr = foo();
for (var i = 0; i < 2; i++) {
print(offsetsPtr.asTypedList(1));
}
calloc.free(offsetsPtr);
}