summaryrefslogtreecommitdiff
path: root/core/fpdfapi
diff options
context:
space:
mode:
Diffstat (limited to 'core/fpdfapi')
-rw-r--r--core/fpdfapi/parser/cfdf_document.cpp16
-rw-r--r--core/fpdfapi/parser/cfdf_document.h14
2 files changed, 18 insertions, 12 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);
}
diff --git a/core/fpdfapi/parser/cfdf_document.h b/core/fpdfapi/parser/cfdf_document.h
index 075119376f..1b47368458 100644
--- a/core/fpdfapi/parser/cfdf_document.h
+++ b/core/fpdfapi/parser/cfdf_document.h
@@ -7,6 +7,8 @@
#ifndef CORE_FPDFAPI_PARSER_CFDF_DOCUMENT_H_
#define CORE_FPDFAPI_PARSER_CFDF_DOCUMENT_H_
+#include <memory>
+
#include "core/fpdfapi/parser/cpdf_indirect_object_holder.h"
#include "core/fpdfapi/parser/cpdf_object.h"
#include "core/fxcrt/fx_basic.h"
@@ -15,17 +17,19 @@ class CPDF_Dictionary;
class CFDF_Document : public CPDF_IndirectObjectHolder {
public:
- static CFDF_Document* CreateNewDoc();
- static CFDF_Document* ParseFile(IFX_SeekableReadStream* pFile,
- bool bOwnFile = false);
- static CFDF_Document* ParseMemory(const uint8_t* pData, uint32_t size);
+ static std::unique_ptr<CFDF_Document> CreateNewDoc();
+ static std::unique_ptr<CFDF_Document> ParseFile(IFX_SeekableReadStream* pFile,
+ bool bOwnFile = false);
+ static std::unique_ptr<CFDF_Document> ParseMemory(const uint8_t* pData,
+ uint32_t size);
+
+ CFDF_Document();
~CFDF_Document() override;
bool WriteBuf(CFX_ByteTextBuf& buf) const;
CPDF_Dictionary* GetRoot() const { return m_pRootDict; }
protected:
- CFDF_Document();
void ParseStream(IFX_SeekableReadStream* pFile, bool bOwnFile);
CPDF_Dictionary* m_pRootDict;