summaryrefslogtreecommitdiff
path: root/fxjs
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-01-11 08:58:35 -0500
committerChromium commit bot <commit-bot@chromium.org>2017-01-11 14:08:42 +0000
commit76a44dea318041f8229d80e70ca3568a435611eb (patch)
tree63928177f2a5fe2ea339cf20b10189f621c2acaf /fxjs
parent98822430907b603d671f8ade5f20723a0f8ecc03 (diff)
downloadpdfium-76a44dea318041f8229d80e70ca3568a435611eb.tar.xz
Cleaning up memory allocation in CXFA_FM2JSContext - IV
This CL removes the use of FX_Alloc and any remaining new'd CFXJSE_Value objects from CXFA_FM2JSContext and replaces them with unique_ptrs and vectors. Change-Id: I30ba697d65ee326d2faa895c3217bdc407419298 Reviewed-on: https://pdfium-review.googlesource.com/2157 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs')
-rw-r--r--fxjs/cfxjse_value.cpp16
-rw-r--r--fxjs/cfxjse_value.h5
2 files changed, 11 insertions, 10 deletions
diff --git a/fxjs/cfxjse_value.cpp b/fxjs/cfxjse_value.cpp
index 471d85cf76..68c82e5deb 100644
--- a/fxjs/cfxjse_value.cpp
+++ b/fxjs/cfxjse_value.cpp
@@ -102,16 +102,14 @@ void CFXJSE_Value::SetHostObject(CFXJSE_HostObject* lpObject,
m_hValue.Reset(m_pIsolate, hObject);
}
-void CFXJSE_Value::SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues) {
+void CFXJSE_Value::SetArray(
+ const std::vector<std::unique_ptr<CFXJSE_Value>>& values) {
CFXJSE_ScopeUtil_IsolateHandleRootContext scope(m_pIsolate);
- v8::Local<v8::Array> hArrayObject = v8::Array::New(m_pIsolate, uValueCount);
- if (rgValues) {
- for (uint32_t i = 0; i < uValueCount; i++) {
- if (rgValues[i]) {
- hArrayObject->Set(i, v8::Local<v8::Value>::New(
- m_pIsolate, rgValues[i]->DirectGetValue()));
- }
- }
+ v8::Local<v8::Array> hArrayObject = v8::Array::New(m_pIsolate, values.size());
+ uint32_t count = 0;
+ for (auto& v : values) {
+ hArrayObject->Set(count++, v8::Local<v8::Value>::New(
+ m_pIsolate, v.get()->DirectGetValue()));
}
m_hValue.Reset(m_pIsolate, hArrayObject);
}
diff --git a/fxjs/cfxjse_value.h b/fxjs/cfxjse_value.h
index 487cf0c6e8..f2ebdc1c25 100644
--- a/fxjs/cfxjse_value.h
+++ b/fxjs/cfxjse_value.h
@@ -7,6 +7,9 @@
#ifndef FXJS_CFXJSE_VALUE_H_
#define FXJS_CFXJSE_VALUE_H_
+#include <memory>
+#include <vector>
+
#include "core/fxcrt/fx_string.h"
#include "core/fxcrt/fx_system.h"
#include "fxjs/cfxjse_isolatetracker.h"
@@ -52,7 +55,7 @@ class CFXJSE_Value {
void SetObject(CFXJSE_HostObject* lpObject, CFXJSE_Class* pClass);
void SetHostObject(CFXJSE_HostObject* lpObject, CFXJSE_Class* lpClass);
- void SetArray(uint32_t uValueCount, CFXJSE_Value** rgValues);
+ void SetArray(const std::vector<std::unique_ptr<CFXJSE_Value>>& values);
void SetDate(double dDouble);
bool GetObjectProperty(const CFX_ByteStringC& szPropName,