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

Unified Diff: core/fpdfapi/parser/cfdf_document.cpp

Issue 2538533003: Make FDF document creation return unique_ptrs (Closed)
Patch Set: Created 4 years, 1 month 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
Index: core/fpdfapi/parser/cfdf_document.cpp
diff --git a/core/fpdfapi/parser/cfdf_document.cpp b/core/fpdfapi/parser/cfdf_document.cpp
index 546308c3a31b8320c439ee491ba16edeffa8d688..41e285245da2b86e07c020c09ef39c70e2d67bff 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);
}

Powered by Google App Engine
This is Rietveld 408576698