diff options
author | Ben Murdoch <benm@google.com> | 2016-11-29 16:50:11 +0000 |
---|---|---|
committer | Ben Murdoch <benm@google.com> | 2017-01-12 12:33:05 +0000 |
commit | f91f0611dbaf29ca0f1d4aecb357ce243a19d2fa (patch) | |
tree | d24b57d9c6d116ea509c621669f8ed7ed8658d3f /samples | |
parent | 28ba1faee73929922c84d2503d2467afa1fea3c3 (diff) | |
download | v8-f91f0611dbaf29ca0f1d4aecb357ce243a19d2fa.tar.gz |
Merge V8 5.4.500.40
Test: Manual - built & ran d8
Change-Id: I4edfa2853d3e565b729723645395688ece3193f4
Diffstat (limited to 'samples')
-rw-r--r-- | samples/hello-world.cc | 16 | ||||
-rw-r--r-- | samples/process.cc | 15 | ||||
-rw-r--r-- | samples/shell.cc | 16 |
3 files changed, 8 insertions, 39 deletions
diff --git a/samples/hello-world.cc b/samples/hello-world.cc index 902d8d55..9e5188f4 100644 --- a/samples/hello-world.cc +++ b/samples/hello-world.cc @@ -11,17 +11,6 @@ using namespace v8; -class ArrayBufferAllocator : 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[]) { // Initialize V8. V8::InitializeICUDefaultLocation(argv[0]); @@ -31,9 +20,9 @@ int main(int argc, char* argv[]) { V8::Initialize(); // Create a new Isolate and make it the current one. - ArrayBufferAllocator allocator; Isolate::CreateParams create_params; - create_params.array_buffer_allocator = &allocator; + create_params.array_buffer_allocator = + v8::ArrayBuffer::Allocator::NewDefaultAllocator(); Isolate* isolate = Isolate::New(create_params); { Isolate::Scope isolate_scope(isolate); @@ -68,5 +57,6 @@ int main(int argc, char* argv[]) { V8::Dispose(); V8::ShutdownPlatform(); delete platform; + delete create_params.array_buffer_allocator; return 0; } diff --git a/samples/process.cc b/samples/process.cc index 54c8376e..29ddb5cf 100644 --- a/samples/process.cc +++ b/samples/process.cc @@ -38,17 +38,6 @@ using namespace std; using namespace v8; -class ArrayBufferAllocator : 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); } -}; - - // These interfaces represent an existing request processing interface. // The idea is to imagine a real application that uses these interfaces // and then add scripting capabilities that allow you to interact with @@ -699,9 +688,9 @@ int main(int argc, char* argv[]) { fprintf(stderr, "No script was specified.\n"); return 1; } - ArrayBufferAllocator array_buffer_allocator; Isolate::CreateParams create_params; - create_params.array_buffer_allocator = &array_buffer_allocator; + create_params.array_buffer_allocator = + v8::ArrayBuffer::Allocator::NewDefaultAllocator(); Isolate* isolate = Isolate::New(create_params); Isolate::Scope isolate_scope(isolate); HandleScope scope(isolate); diff --git a/samples/shell.cc b/samples/shell.cc index ad9b1aba..e042815e 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; } |