summaryrefslogtreecommitdiff
path: root/fxjs/cjs_global.cpp
diff options
context:
space:
mode:
authorTom Sepez <tsepez@chromium.org>2018-09-14 23:07:11 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-09-14 23:07:11 +0000
commit8abd0dfe538fcf55c7c8571791b409d7e036ef54 (patch)
tree39a9775e1295d8b73bc4dcadb3298c6cbb0b1a4f /fxjs/cjs_global.cpp
parentcb88fa33339ca04c89f340b457f4960d0d4185a2 (diff)
downloadpdfium-8abd0dfe538fcf55c7c8571791b409d7e036ef54.tar.xz
Use unique_ptr<> in CJS_GlobalVariableArray::Add().
Clean up another ten bare |new|s or so. Change-Id: If32b307e5edd844488dfb2020e710214bb6f75a0 Reviewed-on: https://pdfium-review.googlesource.com/42550 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'fxjs/cjs_global.cpp')
-rw-r--r--fxjs/cjs_global.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/fxjs/cjs_global.cpp b/fxjs/cjs_global.cpp
index d9338abcfd..ecf06f10cb 100644
--- a/fxjs/cjs_global.cpp
+++ b/fxjs/cjs_global.cpp
@@ -418,43 +418,43 @@ void CJS_Global::ObjectToArray(CJS_Runtime* pRuntime,
ByteString sKey = ws.UTF8Encode();
v8::Local<v8::Value> v = pRuntime->GetObjectProperty(pObj, ws);
if (v->IsNumber()) {
- CJS_KeyValue* pObjElement = new CJS_KeyValue;
+ auto pObjElement = pdfium::MakeUnique<CJS_KeyValue>();
pObjElement->nType = JS_GlobalDataType::NUMBER;
pObjElement->sKey = sKey;
pObjElement->dData = pRuntime->ToDouble(v);
- pArray->Add(pObjElement);
+ pArray->Add(std::move(pObjElement));
continue;
}
if (v->IsBoolean()) {
- CJS_KeyValue* pObjElement = new CJS_KeyValue;
+ auto pObjElement = pdfium::MakeUnique<CJS_KeyValue>();
pObjElement->nType = JS_GlobalDataType::BOOLEAN;
pObjElement->sKey = sKey;
pObjElement->dData = pRuntime->ToBoolean(v);
- pArray->Add(pObjElement);
+ pArray->Add(std::move(pObjElement));
continue;
}
if (v->IsString()) {
ByteString sValue = pRuntime->ToWideString(v).ToDefANSI();
- CJS_KeyValue* pObjElement = new CJS_KeyValue;
+ auto pObjElement = pdfium::MakeUnique<CJS_KeyValue>();
pObjElement->nType = JS_GlobalDataType::STRING;
pObjElement->sKey = sKey;
pObjElement->sData = sValue;
- pArray->Add(pObjElement);
+ pArray->Add(std::move(pObjElement));
continue;
}
if (v->IsObject()) {
- CJS_KeyValue* pObjElement = new CJS_KeyValue;
+ auto pObjElement = pdfium::MakeUnique<CJS_KeyValue>();
pObjElement->nType = JS_GlobalDataType::OBJECT;
pObjElement->sKey = sKey;
ObjectToArray(pRuntime, pRuntime->ToObject(v), &pObjElement->objData);
- pArray->Add(pObjElement);
+ pArray->Add(std::move(pObjElement));
continue;
}
if (v->IsNull()) {
- CJS_KeyValue* pObjElement = new CJS_KeyValue;
+ auto pObjElement = pdfium::MakeUnique<CJS_KeyValue>();
pObjElement->nType = JS_GlobalDataType::NULLOBJ;
pObjElement->sKey = sKey;
- pArray->Add(pObjElement);
+ pArray->Add(std::move(pObjElement));
}
}
}