From 18f7fbca461254cc0df1af2ca586df42b7fd6c17 Mon Sep 17 00:00:00 2001 From: Lei Zhang Date: Thu, 24 May 2018 01:39:31 +0000 Subject: Mark some pointers as non-const in CPDF_NameTree. The class modifies the tree, so stop pretending its const. Change-Id: I1095239a728fc0999c84db37d5cb17f596b9c791 Reviewed-on: https://pdfium-review.googlesource.com/32185 Commit-Queue: Lei Zhang Reviewed-by: Henrique Nakashima --- core/fpdfdoc/cpdf_nametree.cpp | 12 +++++------- core/fpdfdoc/cpdf_nametree.h | 2 +- 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'core/fpdfdoc') diff --git a/core/fpdfdoc/cpdf_nametree.cpp b/core/fpdfdoc/cpdf_nametree.cpp index 3c5b08db21..92b37f12b3 100644 --- a/core/fpdfdoc/cpdf_nametree.cpp +++ b/core/fpdfdoc/cpdf_nametree.cpp @@ -36,7 +36,7 @@ std::pair GetNodeLimitsMaybeSwap(CPDF_Array* pLimits) { // Get the limit arrays that leaf array |pFind| is under in the tree with root // |pNode|. |pLimits| will hold all the limit arrays from the leaf up to before // the root. Return true if successful. -bool GetNodeAncestorsLimits(const CPDF_Dictionary* pNode, +bool GetNodeAncestorsLimits(CPDF_Dictionary* pNode, const CPDF_Array* pFind, int nLevel, std::vector* pLimits) { @@ -153,7 +153,7 @@ bool UpdateNodesAndLimitsUponDeletion(CPDF_Dictionary* pNode, // will be the index of |csName| in |ppFind|. If |csName| is not found, |ppFind| // will be the leaf array that |csName| should be added to, and |pFindIndex| // will be the index that it should be added at. -CPDF_Object* SearchNameNodeByName(const CPDF_Dictionary* pNode, +CPDF_Object* SearchNameNodeByName(CPDF_Dictionary* pNode, const WideString& csName, int nLevel, size_t* nIndex, @@ -228,7 +228,7 @@ CPDF_Object* SearchNameNodeByName(const CPDF_Dictionary* pNode, // successful, return the value object; |csName| will be the key, |ppFind| // will be the leaf array that this pair is in, and |pFindIndex| will be the // index of the pair in |pFind|. -CPDF_Object* SearchNameNodeByIndex(const CPDF_Dictionary* pNode, +CPDF_Object* SearchNameNodeByIndex(CPDF_Dictionary* pNode, size_t nIndex, int nLevel, size_t* nCurIndex, @@ -298,10 +298,8 @@ size_t CountNamesInternal(CPDF_Dictionary* pNode, int nLevel) { CPDF_NameTree::CPDF_NameTree(CPDF_Dictionary* pRoot) : m_pRoot(pRoot) {} -CPDF_NameTree::CPDF_NameTree(const CPDF_Document* pDoc, - const ByteString& category) - : m_pRoot(nullptr) { - const CPDF_Dictionary* pRoot = pDoc->GetRoot(); +CPDF_NameTree::CPDF_NameTree(CPDF_Document* pDoc, const ByteString& category) { + CPDF_Dictionary* pRoot = pDoc->GetRoot(); if (!pRoot) return; diff --git a/core/fpdfdoc/cpdf_nametree.h b/core/fpdfdoc/cpdf_nametree.h index 72d0d669e9..495798c087 100644 --- a/core/fpdfdoc/cpdf_nametree.h +++ b/core/fpdfdoc/cpdf_nametree.h @@ -20,7 +20,7 @@ class CPDF_Object; class CPDF_NameTree { public: explicit CPDF_NameTree(CPDF_Dictionary* pRoot); - CPDF_NameTree(const CPDF_Document* pDoc, const ByteString& category); + CPDF_NameTree(CPDF_Document* pDoc, const ByteString& category); ~CPDF_NameTree(); bool AddValueAndName(std::unique_ptr pObj, -- cgit v1.2.3