From c25394f5d8622fbb6203e73843f84ec1739bfa0b Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 30 Nov 2017 19:52:42 +0000 Subject: Use initializer list in CPDF_DataAvail ctor. Or initialize members in the header. Also make m_dwFileLen member const. Change-Id: Iaaeab9a93e18e4ab313437362c0012d729b01647 Reviewed-on: https://pdfium-review.googlesource.com/9970 Reviewed-by: dsinclair Commit-Queue: Lei Zhang --- core/fpdfapi/parser/cpdf_data_avail.cpp | 27 +++++-------------------- core/fpdfapi/parser/cpdf_data_avail.h | 36 ++++++++++++++++----------------- 2 files changed, 23 insertions(+), 40 deletions(-) (limited to 'core') diff --git a/core/fpdfapi/parser/cpdf_data_avail.cpp b/core/fpdfapi/parser/cpdf_data_avail.cpp index e72d7cdb19..af80fd96ab 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.cpp +++ b/core/fpdfapi/parser/cpdf_data_avail.cpp @@ -79,28 +79,11 @@ CPDF_DataAvail::CPDF_DataAvail( FileAvail* pFileAvail, const RetainPtr& pFileRead, bool bSupportHintTable) - : m_pFileAvail(pFileAvail) { - ASSERT(pFileRead); - m_pFileRead = pdfium::MakeRetain(pFileRead, m_pFileAvail); - m_dwFileLen = m_pFileRead->GetSize(); - m_PagesObjNum = 0; - m_dwInfoObjNum = 0; - m_pDocument = 0; - m_dwEncryptObjNum = 0; - m_bDocAvail = false; - m_bMainXRefLoadTried = false; - m_bDocAvail = false; - m_bPagesLoad = false; - m_bPagesTreeLoad = false; - m_bMainXRefLoadedOK = false; - m_pCurrentParser = nullptr; - m_docStatus = PDF_DATAAVAIL_HEADER; - m_bTotalLoadPageTree = false; - m_bCurPageDictLoadOK = false; - m_bLinearedDataOK = false; - m_bSupportHintTable = bSupportHintTable; - m_bHeaderAvail = false; -} + : m_pFileAvail(pFileAvail), + m_pFileRead( + pdfium::MakeRetain(pFileRead, m_pFileAvail)), + m_dwFileLen(m_pFileRead->GetSize()), + m_bSupportHintTable(bSupportHintTable) {} CPDF_DataAvail::~CPDF_DataAvail() { m_pHintTables.reset(); diff --git a/core/fpdfapi/parser/cpdf_data_avail.h b/core/fpdfapi/parser/cpdf_data_avail.h index 001bf2280f..dfb1f0cabf 100644 --- a/core/fpdfapi/parser/cpdf_data_avail.h +++ b/core/fpdfapi/parser/cpdf_data_avail.h @@ -168,37 +168,37 @@ class CPDF_DataAvail final { RetainPtr m_pFileRead; CPDF_Parser m_parser; std::unique_ptr m_pRoot; - uint32_t m_dwRootObjNum; - uint32_t m_dwInfoObjNum; + uint32_t m_dwRootObjNum = 0; + uint32_t m_dwInfoObjNum = 0; std::unique_ptr m_pLinearized; - bool m_bDocAvail; + bool m_bDocAvail = false; std::unique_ptr m_pCrossRefAvail; - PDF_DATAAVAIL_STATUS m_docStatus; - FX_FILESIZE m_dwFileLen; - CPDF_Document* m_pDocument; + PDF_DATAAVAIL_STATUS m_docStatus = PDF_DATAAVAIL_HEADER; + const FX_FILESIZE m_dwFileLen; + CPDF_Document* m_pDocument = nullptr; std::vector m_PageObjList; - uint32_t m_PagesObjNum; - bool m_bLinearedDataOK; - bool m_bMainXRefLoadTried; - bool m_bMainXRefLoadedOK; - bool m_bPagesTreeLoad; - bool m_bPagesLoad; - CPDF_Parser* m_pCurrentParser; + uint32_t m_PagesObjNum = 0; + bool m_bLinearedDataOK = false; + bool m_bMainXRefLoadTried = false; + bool m_bMainXRefLoadedOK = false; + bool m_bPagesTreeLoad = false; + bool m_bPagesLoad = false; + CPDF_Parser* m_pCurrentParser = nullptr; std::unique_ptr m_pFormAvail; std::vector> m_PagesArray; - uint32_t m_dwEncryptObjNum; - bool m_bTotalLoadPageTree; - bool m_bCurPageDictLoadOK; + uint32_t m_dwEncryptObjNum = 0; + bool m_bTotalLoadPageTree = false; + bool m_bCurPageDictLoadOK = false; PageNode m_PageNode; std::set m_pageMapCheckState; std::set m_pagesLoadState; std::set m_SeenPrevPositions; std::unique_ptr m_pHintTables; - bool m_bSupportHintTable; + const bool m_bSupportHintTable; std::map> m_PagesObjAvail; std::map> m_PagesResourcesAvail; - bool m_bHeaderAvail; + bool m_bHeaderAvail = false; }; #endif // CORE_FPDFAPI_PARSER_CPDF_DATA_AVAIL_H_ -- cgit v1.2.3