summaryrefslogtreecommitdiff
path: root/xfa/fde/xml/cfde_xmlsyntaxparser.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-04-05 16:34:44 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-04-05 21:11:15 +0000
commit480f62b8350f17a398cbf4f02b76b4368a62dce6 (patch)
tree210b891000969392c87506f2c4b616a3f66d6d08 /xfa/fde/xml/cfde_xmlsyntaxparser.cpp
parent3c67fbdbabee4195b72d1bd1d568cad3ecad9e96 (diff)
downloadpdfium-480f62b8350f17a398cbf4f02b76b4368a62dce6.tar.xz
Merge XMLSyntaxParser Init into constructor
This Init() method is always called right after construction. Merge together for clarity. Change-Id: Iab5bfe937e82b7a310e373dd139399bc1be7cea6 Reviewed-on: https://pdfium-review.googlesource.com/3814 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fde/xml/cfde_xmlsyntaxparser.cpp')
-rw-r--r--xfa/fde/xml/cfde_xmlsyntaxparser.cpp28
1 files changed, 10 insertions, 18 deletions
diff --git a/xfa/fde/xml/cfde_xmlsyntaxparser.cpp b/xfa/fde/xml/cfde_xmlsyntaxparser.cpp
index 93f8f1d51f..ea4af42f9e 100644
--- a/xfa/fde/xml/cfde_xmlsyntaxparser.cpp
+++ b/xfa/fde/xml/cfde_xmlsyntaxparser.cpp
@@ -77,9 +77,10 @@ int32_t GetUTF8EncodeLength(const wchar_t* pSrc, int32_t iSrcLen) {
} // namespace
-CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser()
- : m_pStream(nullptr),
- m_iXMLPlaneSize(-1),
+CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser(
+ const CFX_RetainPtr<IFGAS_Stream>& pStream)
+ : m_pStream(pStream),
+ m_iXMLPlaneSize(32 * 1024),
m_iCurrentPos(0),
m_iCurrentNodeNum(-1),
m_iLastNodeNum(-1),
@@ -99,21 +100,15 @@ CFDE_XMLSyntaxParser::CFDE_XMLSyntaxParser()
m_syntaxParserState(FDE_XmlSyntaxState::Text),
m_wQuotationMark(0),
m_iEntityStart(-1) {
+ ASSERT(pStream);
+
m_CurNode.iNodeNum = -1;
m_CurNode.eNodeType = FDE_XMLNODE_Unknown;
-}
-void CFDE_XMLSyntaxParser::Init(const CFX_RetainPtr<IFGAS_Stream>& pStream,
- int32_t iXMLPlaneSize) {
- ASSERT(!m_pStream && !m_pBuffer);
- ASSERT(pStream && iXMLPlaneSize > 0);
- int32_t iStreamLength = pStream->GetLength();
- ASSERT(iStreamLength > 0);
- m_pStream = pStream;
- m_iXMLPlaneSize = std::min(iXMLPlaneSize, iStreamLength);
+ m_iXMLPlaneSize = std::min(m_iXMLPlaneSize, m_pStream->GetLength());
+
uint8_t bom[4];
m_iCurrentPos = m_pStream->GetBOM(bom);
- ASSERT(!m_pBuffer);
FX_SAFE_INT32 alloc_size_safe = m_iXMLPlaneSize;
alloc_size_safe += 1; // For NUL.
@@ -124,14 +119,12 @@ void CFDE_XMLSyntaxParser::Init(const CFX_RetainPtr<IFGAS_Stream>& pStream,
m_pBuffer = FX_Alloc(
wchar_t, pdfium::base::ValueOrDieForType<size_t>(alloc_size_safe));
- m_pStart = m_pEnd = m_pBuffer;
+ m_pStart = m_pBuffer;
+ m_pEnd = m_pBuffer;
- ASSERT(!m_BlockBuffer.IsInitialized());
m_BlockBuffer.InitBuffer();
std::tie(m_pCurrentBlock, m_iIndexInBlock) =
m_BlockBuffer.GetAvailableBlock();
- m_iParsedBytes = m_iParsedChars = 0;
- m_iBufferChars = 0;
}
FDE_XmlSyntaxResult CFDE_XMLSyntaxParser::DoSyntaxParse() {
@@ -600,7 +593,6 @@ FDE_XmlSyntaxResult CFDE_XMLSyntaxParser::DoSyntaxParse() {
}
CFDE_XMLSyntaxParser::~CFDE_XMLSyntaxParser() {
- m_pCurrentBlock = nullptr;
FX_Free(m_pBuffer);
}