mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 22:41:41 +00:00
c1212311bf
Reland 1d6c1020c9
with the fix for ASAN
bots.
* Test standalone_2/file_error_test is updated for Dart 2.0 fixed-size
integers.
* This update revealed that certain dart:io native methods do not handle
out-of-memory properly when I/O buffers are allocated.
This CL fixes this bug.
* Updated test point is extracted to a separate test
standalone_2/file_error2_test as it needs custom ASAN options.
Change-Id: Ifb1fa59828f36dc03d45c18a41d45da6b989d70a
Reviewed-on: https://dart-review.googlesource.com/20908
Reviewed-by: Zach Anderson <zra@google.com>
Commit-Queue: Alexander Markov <alexmarkov@google.com>
43 lines
1.2 KiB
C++
43 lines
1.2 KiB
C++
// Copyright (c) 2012, 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.
|
|
|
|
#ifndef RUNTIME_BIN_IO_BUFFER_H_
|
|
#define RUNTIME_BIN_IO_BUFFER_H_
|
|
|
|
#include "include/dart_api.h"
|
|
#include "platform/globals.h"
|
|
|
|
namespace dart {
|
|
namespace bin {
|
|
|
|
class IOBuffer {
|
|
public:
|
|
// Allocate an IO buffer dart object (of type Uint8List) backed by
|
|
// an external byte array.
|
|
static Dart_Handle Allocate(intptr_t size, uint8_t** buffer);
|
|
|
|
// Allocate IO buffer storage.
|
|
static uint8_t* Allocate(intptr_t size);
|
|
|
|
// Function for disposing of IO buffer storage. All backing storage
|
|
// for IO buffers must be freed using this function.
|
|
static void Free(void* buffer) { free(buffer); }
|
|
|
|
// Function for finalizing external byte arrays used as IO buffers.
|
|
static void Finalizer(void* isolate_callback_data,
|
|
Dart_WeakPersistentHandle handle,
|
|
void* buffer) {
|
|
Free(buffer);
|
|
}
|
|
|
|
private:
|
|
DISALLOW_ALLOCATION();
|
|
DISALLOW_IMPLICIT_CONSTRUCTORS(IOBuffer);
|
|
};
|
|
|
|
} // namespace bin
|
|
} // namespace dart
|
|
|
|
#endif // RUNTIME_BIN_IO_BUFFER_H_
|