| Index: samples/shell.cc
|
| diff --git a/samples/shell.cc b/samples/shell.cc
|
| index 1a08afffdc8ad211ec10adb898ab943427ed1b5b..a37593678edbe8b61aae9710ca74d79af45b495d 100644
|
| --- a/samples/shell.cc
|
| +++ b/samples/shell.cc
|
| @@ -35,6 +35,14 @@
|
| #include <stdlib.h>
|
| #include <string.h>
|
|
|
| +#if V8_OS_WIN
|
| +#include <malloc.h>
|
| +#endif
|
| +
|
| +#ifdef COMPRESS_STARTUP_DATA_BZ2
|
| +#error Using compressed startup data is not supported for this sample
|
| +#endif
|
| +
|
| /**
|
| * This sample program shows how to implement a simple javascript shell
|
| * based on V8. This includes initializing V8 with command line options,
|
| @@ -70,8 +78,28 @@ class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
|
| 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); }
|
| + virtual void* AllocateUninitialized(size_t length) {
|
| + return Allocate(length, 8);
|
| + }
|
| + virtual void* Allocate(size_t length, size_t alignment) {
|
| +#if V8_OS_ANDROID
|
| + return memalign(alignment, length);
|
| +#elif V8_OS_WIN
|
| + return _aligned_malloc(length, alignment);
|
| +#else
|
| + void* ptr = NULL;
|
| + posix_memalign(&ptr, alignment, length);
|
| + return ptr;
|
| +#endif
|
| + }
|
| + virtual void Free(void* data, size_t) { Free(data); }
|
| + virtual void Free(void* data) {
|
| +#if V8_OS_WIN
|
| + _aligned_free(data);
|
| +#else
|
| + free(data);
|
| +#endif
|
| + }
|
| };
|
|
|
|
|
|
|