Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
io_buffer.h
Go to the documentation of this file.
1// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_BIN_IO_BUFFER_H_
6#define RUNTIME_BIN_IO_BUFFER_H_
7
8#include "include/dart_api.h"
9#include "platform/globals.h"
10
11namespace dart {
12namespace bin {
13
14class IOBuffer {
15 public:
16 // Allocate an IO buffer dart object (of type Uint8List) backed by
17 // an external byte array.
18 static Dart_Handle Allocate(intptr_t size, uint8_t** buffer);
19
20 // Allocate IO buffer storage.
21 static uint8_t* Allocate(intptr_t size);
22
23 // Reallocate IO buffer storage.
24 static uint8_t* Reallocate(uint8_t* buffer, intptr_t new_size);
25
26 // Function for disposing of IO buffer storage. All backing storage
27 // for IO buffers must be freed using this function.
28 static void Free(void* buffer) { free(buffer); }
29
30 // Function for finalizing external byte arrays used as IO buffers.
31 static void Finalizer(void* isolate_callback_data, void* buffer) {
32 Free(buffer);
33 }
34
35 private:
36 DISALLOW_ALLOCATION();
38};
39
40} // namespace bin
41} // namespace dart
42
43#endif // RUNTIME_BIN_IO_BUFFER_H_
static void Free(void *buffer)
Definition io_buffer.h:28
static void Finalizer(void *isolate_callback_data, void *buffer)
Definition io_buffer.h:31
static Dart_Handle Allocate(intptr_t size, uint8_t **buffer)
Definition io_buffer.cc:12
static uint8_t * Reallocate(uint8_t *buffer, intptr_t new_size)
Definition io_buffer.cc:34
struct _Dart_Handle * Dart_Handle
Definition dart_api.h:258
static const uint8_t buffer[]
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
Definition globals.h:593