diff options
Diffstat (limited to 'fpdfsdk/fpdf_dataavail.cpp')
-rw-r--r-- | fpdfsdk/fpdf_dataavail.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/fpdfsdk/fpdf_dataavail.cpp b/fpdfsdk/fpdf_dataavail.cpp index b1bc1e3bc0..f2358d2e5c 100644 --- a/fpdfsdk/fpdf_dataavail.cpp +++ b/fpdfsdk/fpdf_dataavail.cpp @@ -60,9 +60,9 @@ class CFPDF_FileAvailWrap : public CPDF_DataAvail::FileAvail { class CFPDF_FileAccessWrap : public IFX_SeekableReadStream { public: - static CFX_RetainPtr<CFPDF_FileAccessWrap> Create() { - return CFX_RetainPtr<CFPDF_FileAccessWrap>(new CFPDF_FileAccessWrap()); - } + template <typename T, typename... Args> + friend CFX_RetainPtr<T> pdfium::MakeRetain(Args&&... args); + ~CFPDF_FileAccessWrap() override {} void Set(FPDF_FILEACCESS* pFile) { m_pFileAccess = pFile; } @@ -101,8 +101,8 @@ class CFPDF_DownloadHintsWrap : public CPDF_DataAvail::DownloadHints { class CFPDF_DataAvail { public: CFPDF_DataAvail() - : m_FileAvail(new CFPDF_FileAvailWrap), - m_FileRead(CFPDF_FileAccessWrap::Create()) {} + : m_FileAvail(pdfium::MakeUnique<CFPDF_FileAvailWrap>()), + m_FileRead(pdfium::MakeRetain<CFPDF_FileAccessWrap>()) {} ~CFPDF_DataAvail() {} std::unique_ptr<CPDF_DataAvail> m_pDataAvail; @@ -145,11 +145,10 @@ FPDFAvail_GetDocument(FPDF_AVAIL avail, FPDF_BYTESTRING password) { if (!pDataAvail) return nullptr; - std::unique_ptr<CPDF_Parser> pParser(new CPDF_Parser); + auto pParser = pdfium::MakeUnique<CPDF_Parser>(); pParser->SetPassword(password); - std::unique_ptr<CPDF_Document> pDocument( - new CPDF_Document(std::move(pParser))); + auto pDocument = pdfium::MakeUnique<CPDF_Document>(std::move(pParser)); CPDF_Parser::Error error = pDocument->GetParser()->StartLinearizedParse( pDataAvail->m_pDataAvail->GetFileRead(), pDocument.get()); if (error != CPDF_Parser::SUCCESS) { |