summaryrefslogtreecommitdiff
path: root/core/fpdfapi/parser/cfdf_document.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-11-28 17:30:09 -0800
committerCommit bot <commit-bot@chromium.org>2016-11-28 17:30:09 -0800
commit05e01698444726fae302cd335fa4880932d7c543 (patch)
tree011f7693d29e4c6726966fa1b13d5a075a1a8dea /core/fpdfapi/parser/cfdf_document.cpp
parent405ac0f09e1622d7ff3cf60314d290851ac9f7fd (diff)
downloadpdfium-05e01698444726fae302cd335fa4880932d7c543.tar.xz
Make FDF document creation return unique_ptrs
Review-Url: https://codereview.chromium.org/2538533003
Diffstat (limited to 'core/fpdfapi/parser/cfdf_document.cpp')
-rw-r--r--core/fpdfapi/parser/cfdf_document.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/core/fpdfapi/parser/cfdf_document.cpp b/core/fpdfapi/parser/cfdf_document.cpp
index 546308c3a3..41e285245d 100644
--- a/core/fpdfapi/parser/cfdf_document.cpp
+++ b/core/fpdfapi/parser/cfdf_document.cpp
@@ -25,24 +25,26 @@ CFDF_Document::~CFDF_Document() {
m_pFile->Release();
}
-CFDF_Document* CFDF_Document::CreateNewDoc() {
- CFDF_Document* pDoc = new CFDF_Document;
+std::unique_ptr<CFDF_Document> CFDF_Document::CreateNewDoc() {
+ auto pDoc = pdfium::MakeUnique<CFDF_Document>();
pDoc->m_pRootDict = pDoc->NewIndirect<CPDF_Dictionary>();
pDoc->m_pRootDict->SetNewFor<CPDF_Dictionary>("FDF");
return pDoc;
}
-CFDF_Document* CFDF_Document::ParseFile(IFX_SeekableReadStream* pFile,
- bool bOwnFile) {
+std::unique_ptr<CFDF_Document> CFDF_Document::ParseFile(
+ IFX_SeekableReadStream* pFile,
+ bool bOwnFile) {
if (!pFile)
return nullptr;
- std::unique_ptr<CFDF_Document> pDoc(new CFDF_Document);
+ auto pDoc = pdfium::MakeUnique<CFDF_Document>();
pDoc->ParseStream(pFile, bOwnFile);
- return pDoc->m_pRootDict ? pDoc.release() : nullptr;
+ return pDoc->m_pRootDict ? std::move(pDoc) : nullptr;
}
-CFDF_Document* CFDF_Document::ParseMemory(const uint8_t* pData, uint32_t size) {
+std::unique_ptr<CFDF_Document> CFDF_Document::ParseMemory(const uint8_t* pData,
+ uint32_t size) {
return CFDF_Document::ParseFile(FX_CreateMemoryStream((uint8_t*)pData, size),
true);
}