From 4536a47bc4581a5344fba9c5491464bf9b7261c9 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Fri, 28 Apr 2017 15:27:54 -0700 Subject: Remove some more |new|s, part 4. FindMatchingDataNode(): The callers that passed null iterators, triggering the new, are perfectly capable of making their own iterators. Change-Id: I712fa36667d6070b43f237916e448d518e8855c2 Reviewed-on: https://pdfium-review.googlesource.com/4616 Reviewed-by: Lei Zhang Commit-Queue: Tom Sepez --- xfa/fxfa/parser/xfa_document_datamerger_imp.cpp | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp index 46a2af4a76..ab6f155ae5 100644 --- a/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp +++ b/xfa/fxfa/parser/xfa_document_datamerger_imp.cpp @@ -551,16 +551,9 @@ CXFA_Node* FindMatchingDataNode( bool& bSelfMatch, XFA_ATTRIBUTEENUM& eBindMatch, bool bUpLevel) { - bool bOwnIterator = false; - if (!pIterator) { - bOwnIterator = true; - pIterator = new CXFA_NodeIteratorTemplate< - CXFA_Node, CXFA_TraverseStrategy_XFAContainerNode>(pTemplateNode); - } - CXFA_Node* pResult = nullptr; - for (CXFA_Node* pCurTemplateNode = pIterator->GetCurrent(); - pCurTemplateNode;) { + CXFA_Node* pCurTemplateNode = pIterator->GetCurrent(); + while (pCurTemplateNode) { XFA_Element eMatchNodeType; switch (pCurTemplateNode->GetElementType()) { case XFA_Element::Subform: @@ -650,8 +643,6 @@ CXFA_Node* FindMatchingDataNode( bSelfMatch = true; break; } - if (bOwnIterator) - delete pIterator; return pResult; } @@ -823,9 +814,12 @@ CXFA_Node* CopyContainer_SubformSet(CXFA_Document* pDocument, bSelfMatch = false; eBindMatch = XFA_ATTRIBUTEENUM_None; if (eRelation != XFA_ATTRIBUTEENUM_Ordered) { + CXFA_NodeIteratorTemplate + sChildIter(pTemplateChild); CXFA_Node* pDataMatch = FindMatchingDataNode( pDocument, pTemplateChild, pDataScope, bAccessedDataDOM, - false, nullptr, bSelfMatch, eBindMatch, true); + false, &sChildIter, bSelfMatch, eBindMatch, true); if (pDataMatch) { RecurseRecord sNewRecord = {pTemplateChild, pDataMatch}; if (bSelfMatch) @@ -989,9 +983,11 @@ CXFA_Node* CopyContainer_Field(CXFA_Document* pDocument, bool bAccessedDataDOM = false; bool bSelfMatch = false; XFA_ATTRIBUTEENUM eBindMatch; + CXFA_NodeIteratorTemplate + sNodeIter(pTemplateNode); CXFA_Node* pDataNode = FindMatchingDataNode( - pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, true, nullptr, - bSelfMatch, eBindMatch, bUpLevel); + pDocument, pTemplateNode, pDataScope, bAccessedDataDOM, true, + &sNodeIter, bSelfMatch, eBindMatch, bUpLevel); if (pDataNode) CreateDataBinding(pFieldNode, pDataNode, true); } else { -- cgit v1.2.3