Index: samples/process.cc |
diff --git a/samples/process.cc b/samples/process.cc |
index e0c273e08a9aa281927287b3bb5f0e6716f0fbbc..060c0e852d93bc2763f8b81d21047f903c79e4ae 100644 |
--- a/samples/process.cc |
+++ b/samples/process.cc |
@@ -29,12 +29,25 @@ |
#include <include/libplatform/libplatform.h> |
+#include <string.h> |
+ |
#include <map> |
#include <string> |
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 |
@@ -648,6 +661,8 @@ int main(int argc, char* argv[]) { |
v8::V8::InitializeICU(); |
v8::Platform* platform = v8::platform::CreateDefaultPlatform(); |
v8::V8::InitializePlatform(platform); |
+ ArrayBufferAllocator array_buffer_allocator; |
+ v8::V8::SetArrayBufferAllocator(&array_buffer_allocator); |
v8::V8::Initialize(); |
map<string, string> options; |
string file; |