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

Unified Diff: samples/shell.cc

Issue 2101413002: Provide a convenience array buffer allocator (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 6 months 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 | « samples/process.cc ('k') | src/api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: samples/shell.cc
diff --git a/samples/shell.cc b/samples/shell.cc
index ad9b1aba8bfd8b30be150bccb489f2ee31c4240f..e042815e7a7151d3b51c3e44d2a55dd03980f6e0 100644
--- a/samples/shell.cc
+++ b/samples/shell.cc
@@ -63,17 +63,6 @@ void ReportException(v8::Isolate* isolate, v8::TryCatch* handler);
static bool run_shell;
-class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
- public:
- virtual void* Allocate(size_t length) {
- void* data = AllocateUninitialized(length);
- return data == NULL ? data : memset(data, 0, length);
- }
- virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
- virtual void Free(void* data, size_t) { free(data); }
-};
-
-
int main(int argc, char* argv[]) {
v8::V8::InitializeICUDefaultLocation(argv[0]);
v8::V8::InitializeExternalStartupData(argv[0]);
@@ -81,9 +70,9 @@ int main(int argc, char* argv[]) {
v8::V8::InitializePlatform(platform);
v8::V8::Initialize();
v8::V8::SetFlagsFromCommandLine(&argc, argv, true);
- ShellArrayBufferAllocator array_buffer_allocator;
v8::Isolate::CreateParams create_params;
- create_params.array_buffer_allocator = &array_buffer_allocator;
+ create_params.array_buffer_allocator =
+ v8::ArrayBuffer::Allocator::NewDefaultAllocator();
v8::Isolate* isolate = v8::Isolate::New(create_params);
run_shell = (argc == 1);
int result;
@@ -103,6 +92,7 @@ int main(int argc, char* argv[]) {
v8::V8::Dispose();
v8::V8::ShutdownPlatform();
delete platform;
+ delete create_params.array_buffer_allocator;
return result;
}
« no previous file with comments | « samples/process.cc ('k') | src/api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698