From 38f6d9d1134a23d9319a4efc3ac6e3f824d2ac40 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Tue, 21 Mar 2017 16:15:55 -0700 Subject: Use unique_ptr in cfx_saxreader.h Change-Id: Ia024aff32e7e6fb2d5f6454b9856518a76365de2 Reviewed-on: https://pdfium-review.googlesource.com/3142 Commit-Queue: dsinclair Reviewed-by: dsinclair --- xfa/fde/xml/cfx_saxreader.cpp | 6 +++--- xfa/fde/xml/cfx_saxreader.h | 10 ++++------ 2 files changed, 7 insertions(+), 9 deletions(-) (limited to 'xfa/fde/xml') diff --git a/xfa/fde/xml/cfx_saxreader.cpp b/xfa/fde/xml/cfx_saxreader.cpp index 552ec5f5fe..dfef595f8d 100644 --- a/xfa/fde/xml/cfx_saxreader.cpp +++ b/xfa/fde/xml/cfx_saxreader.cpp @@ -156,8 +156,7 @@ void CFX_SAXReader::Reset() { m_iEntityStart = -1; m_iNameLength = 0; m_iDataPos = 0; - delete m_pCommentContext; - m_pCommentContext = nullptr; + m_pCommentContext.reset(); } void CFX_SAXReader::Push() { @@ -395,7 +394,7 @@ void CFX_SAXReader::ParseDeclOrComment() { m_eMode = CFX_SaxMode::Comment; GetCurrentItem()->m_eNode = CFX_SAXItem::Type::Comment; if (!m_pCommentContext) - m_pCommentContext = new CFX_SAXCommentContext; + m_pCommentContext = pdfium::MakeUnique(); m_pCommentContext->m_iHeaderCount = 1; m_pCommentContext->m_iTailCount = 0; return; @@ -412,6 +411,7 @@ void CFX_SAXReader::ParseComment() { m_dwNodePos = m_File.m_dwCur + m_File.m_dwBufIndex; m_eMode = CFX_SaxMode::CommentContent; } + void CFX_SAXReader::ParseCommentContent() { if (m_CurByte == '-') { m_pCommentContext->m_iTailCount++; diff --git a/xfa/fde/xml/cfx_saxreader.h b/xfa/fde/xml/cfx_saxreader.h index 4e36615429..a5973c699e 100644 --- a/xfa/fde/xml/cfx_saxreader.h +++ b/xfa/fde/xml/cfx_saxreader.h @@ -12,7 +12,10 @@ #include "core/fxcrt/fx_basic.h" +class CFX_SAXCommentContext; class CXFA_SAXContext; +class CXFA_SAXReaderHandler; +enum class CFX_SaxMode; class CFX_SAXItem { public: @@ -55,9 +58,6 @@ class CFX_SAXFile { uint32_t m_dwBufIndex; }; -class CFX_SAXCommentContext; -enum class CFX_SaxMode; - enum CFX_SaxParseMode { CFX_SaxParseMode_NotConvert_amp = 1 << 0, CFX_SaxParseMode_NotConvert_lt = 1 << 1, @@ -68,8 +68,6 @@ enum CFX_SaxParseMode { CFX_SaxParseMode_NotSkipSpace = 1 << 6 }; -class CXFA_SAXReaderHandler; - class CFX_SAXReader { public: CFX_SAXReader(); @@ -140,7 +138,7 @@ class CFX_SAXReader { int32_t m_iNameSize; int32_t m_iNameLength; uint32_t m_dwParseMode; - CFX_SAXCommentContext* m_pCommentContext; + std::unique_ptr m_pCommentContext; }; #endif // XFA_FDE_XML_CFX_SAXREADER_H_ -- cgit v1.2.3