diff options
author | Tom Sepez <tsepez@chromium.org> | 2015-04-30 15:19:03 -0700 |
---|---|---|
committer | Tom Sepez <tsepez@chromium.org> | 2015-04-30 15:19:03 -0700 |
commit | d2cc1b90fe1ffd3162bb685a3f120f867220b5e9 (patch) | |
tree | d3004cd4b3e7c1296fbbdacc7cd68c6c4473655a /xfa/src | |
parent | 134eb282dfaf1e3903979d397db6433966837687 (diff) | |
download | pdfium-d2cc1b90fe1ffd3162bb685a3f120f867220b5e9.tar.xz |
Merge to XFA: Fix V8 array buffer allocator.
R=thestig@chromium.org
Review URL: https://codereview.chromium.org/1118143003
Diffstat (limited to 'xfa/src')
-rw-r--r-- | xfa/src/fxjse/src/runtime.cpp | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/xfa/src/fxjse/src/runtime.cpp b/xfa/src/fxjse/src/runtime.cpp index c4dc61c249..d880606551 100644 --- a/xfa/src/fxjse/src/runtime.cpp +++ b/xfa/src/fxjse/src/runtime.cpp @@ -8,6 +8,21 @@ #include "fxv8.h"
#include "runtime.h"
#include "scope_inline.h"
+
+// Duplicates fpdfsdk's JS_Runtime.h, but keeps XFA from depending on it.
+// TODO(tsepez): make a single version of this.
+class FXJSE_ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
+ void* Allocate(size_t length) override {
+ return calloc(1, length);
+ }
+ void* AllocateUninitialized(size_t length) override {
+ return malloc(length);
+ }
+ void Free(void* data, size_t length) override {
+ free(data);
+ }
+};
+
static void FXJSE_KillV8()
{
v8::V8::Dispose();
@@ -51,7 +66,9 @@ void FXJSE_Finalize() }
FXJSE_HRUNTIME FXJSE_Runtime_Create()
{
- v8::Isolate* pIsolate = v8::Isolate::New();
+ v8::Isolate::CreateParams params;
+ params.array_buffer_allocator = new FXJSE_ArrayBufferAllocator();
+ v8::Isolate* pIsolate = v8::Isolate::New(params);
ASSERT(pIsolate && CFXJSE_RuntimeData::g_RuntimeList);
CFXJSE_RuntimeData::g_RuntimeList->AppendRuntime(pIsolate);
return reinterpret_cast<FXJSE_HRUNTIME>(pIsolate);
|