From 0d2cef0cbaea985fc2dc7061aaaa81c96e2558ff Mon Sep 17 00:00:00 2001 From: Dmitry-Me Date: Fri, 25 Nov 2016 18:39:52 +0300 Subject: [PATCH] Reuse code for error clearing --- tinyxml2.cpp | 6 ++---- tinyxml2.h | 4 ++++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tinyxml2.cpp b/tinyxml2.cpp index 826eb9b..6ce4332 100755 --- a/tinyxml2.cpp +++ b/tinyxml2.cpp @@ -1955,9 +1955,7 @@ void XMLDocument::Clear() #ifdef DEBUG const bool hadError = Error(); #endif - _errorID = XML_SUCCESS; - _errorStr1.Reset(); - _errorStr2.Reset(); + ClearError(); delete [] _charBuffer; _charBuffer = 0; @@ -2162,7 +2160,7 @@ XMLError XMLDocument::SaveFile( FILE* fp, bool compact ) { // Clear any error from the last save, otherwise it will get reported // for *this* call. - SetError(XML_SUCCESS, 0, 0); + ClearError(); XMLPrinter stream( fp, compact ); Print( &stream ); return _errorID; diff --git a/tinyxml2.h b/tinyxml2.h index 12b204f..bafc4f2 100755 --- a/tinyxml2.h +++ b/tinyxml2.h @@ -1740,6 +1740,10 @@ public: void SetError( XMLError error, const char* str1, const char* str2 ); + void ClearError() { + SetError(XML_SUCCESS, 0, 0); + } + /// Return true if there was an error parsing the document. bool Error() const { return _errorID != XML_SUCCESS;