Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(787)

Unified Diff: runtime/bin/dartutils.cc

Issue 11438045: Make all allocation of external arrays used for IO use the IOBuffer class (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/file.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/dartutils.cc
diff --git a/runtime/bin/dartutils.cc b/runtime/bin/dartutils.cc
index 339b036869130f4aa9e1a7f286b43844905ddbc6..6257db653b094b879a50c19944d3bc52e1f99bdb 100644
--- a/runtime/bin/dartutils.cc
+++ b/runtime/bin/dartutils.cc
@@ -7,6 +7,7 @@
#include "bin/extensions.h"
#include "bin/directory.h"
#include "bin/file.h"
+#include "bin/io_buffer.h"
#include "include/dart_api.h"
#include "platform/assert.h"
#include "platform/globals.h"
@@ -671,6 +672,20 @@ Dart_CObject* CObject::NewExternalUint8Array(int64_t length,
}
+Dart_CObject* CObject::NewIOBuffer(int64_t length) {
+ uint8_t* data = IOBuffer::Allocate(length);
+ return NewExternalUint8Array(length, data, data, IOBuffer::Free);
+}
+
+
+void CObject::FreeIOBufferData(Dart_CObject* cobject) {
+ ASSERT(cobject->type == Dart_CObject::kExternalUint8Array);
+ cobject->value.as_external_byte_array.callback(
+ cobject->value.as_external_byte_array.peer);
+ cobject->value.as_external_byte_array.data = NULL;
+}
+
+
static int kArgumentError = 1;
static int kOSError = 2;
static int kFileClosedError = 3;
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698