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

Unified Diff: xfa/src/fxjse/src/runtime.cpp

Issue 1118143003: Merge to XFA: Fix V8 array buffer allocator. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Tabify. Created 5 years, 8 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 | « fpdfsdk/src/javascript/JS_Runtime.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: xfa/src/fxjse/src/runtime.cpp
diff --git a/xfa/src/fxjse/src/runtime.cpp b/xfa/src/fxjse/src/runtime.cpp
index c4dc61c2493bebf317a71fabf7b2c06a0dbb6bee..d88060655121faf7caacaf747ce18761b085ecb3 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);
« no previous file with comments | « fpdfsdk/src/javascript/JS_Runtime.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698