mirror of
https://github.com/leethomason/tinyxml2.git
synced 2026-07-29 23:22:59 +04:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7589178395 |
+3
-17
@@ -114,9 +114,6 @@ distribution.
|
|||||||
#define TIXML_VSNPRINTF vsnprintf
|
#define TIXML_VSNPRINTF vsnprintf
|
||||||
static inline int TIXML_VSCPRINTF( const char* format, va_list va )
|
static inline int TIXML_VSCPRINTF( const char* format, va_list va )
|
||||||
{
|
{
|
||||||
if (!format) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
int len = vsnprintf( 0, 0, format, va );
|
int len = vsnprintf( 0, 0, format, va );
|
||||||
TIXMLASSERT( len >= 0 );
|
TIXMLASSERT( len >= 0 );
|
||||||
return len;
|
return len;
|
||||||
@@ -834,17 +831,7 @@ XMLNode::XMLNode( XMLDocument* doc ) :
|
|||||||
|
|
||||||
XMLNode::~XMLNode()
|
XMLNode::~XMLNode()
|
||||||
{
|
{
|
||||||
// Fast path: this node is dying, so maintaining _firstChild/_lastChild and
|
DeleteChildren();
|
||||||
// sibling _prev/_next links is unnecessary. Only _parent must be zeroed to
|
|
||||||
// satisfy the MarkInUse assertion inside DeleteNode.
|
|
||||||
XMLNode *currentChild = _firstChild;
|
|
||||||
while (currentChild != NULL) {
|
|
||||||
XMLNode *next = currentChild->_next;
|
|
||||||
currentChild->_parent = 0;
|
|
||||||
DeleteNode(currentChild);
|
|
||||||
currentChild = next;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( _parent ) {
|
if ( _parent ) {
|
||||||
_parent->Unlink( this );
|
_parent->Unlink( this );
|
||||||
}
|
}
|
||||||
@@ -2358,9 +2345,8 @@ static FILE* callfopen( const char* filepath, const char* mode )
|
|||||||
}
|
}
|
||||||
|
|
||||||
void XMLDocument::DeleteNode( XMLNode* node ) {
|
void XMLDocument::DeleteNode( XMLNode* node ) {
|
||||||
if(node == 0) {
|
TIXMLASSERT( node );
|
||||||
return; // check for null pointer
|
TIXMLASSERT(node->_document == this );
|
||||||
}
|
|
||||||
if (node->_parent) {
|
if (node->_parent) {
|
||||||
node->_parent->DeleteChild( node );
|
node->_parent->DeleteChild( node );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,14 @@ distribution.
|
|||||||
#endif
|
#endif
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
gcc:
|
||||||
|
g++ -Wall -DTINYXML2_DEBUG tinyxml2.cpp xmltest.cpp -o gccxmltest.exe
|
||||||
|
|
||||||
|
Formatting, Artistic Style:
|
||||||
|
AStyle.exe --style=1tbs --indent-switches --break-closing-brackets --indent-preprocessor tinyxml2.cpp tinyxml2.h
|
||||||
|
*/
|
||||||
|
|
||||||
#if defined( _DEBUG ) || defined (__DEBUG__)
|
#if defined( _DEBUG ) || defined (__DEBUG__)
|
||||||
# ifndef TINYXML2_DEBUG
|
# ifndef TINYXML2_DEBUG
|
||||||
# define TINYXML2_DEBUG
|
# define TINYXML2_DEBUG
|
||||||
|
|||||||
@@ -2025,12 +2025,6 @@ int main( int argc, const char ** argv )
|
|||||||
XMLTest("Parse nested elements with pedantic whitespace", false, doc.Error());
|
XMLTest("Parse nested elements with pedantic whitespace", false, doc.Error());
|
||||||
XMLTest("Pedantic whitespace", true, 0 == doc.RootElement()->FirstChildElement()->GetText());
|
XMLTest("Pedantic whitespace", true, 0 == doc.RootElement()->FirstChildElement()->GetText());
|
||||||
}
|
}
|
||||||
//Check the robustness of the DeleteNode function in handling null pointers.
|
|
||||||
{
|
|
||||||
XMLDocument doc;
|
|
||||||
doc.DeleteNode(nullptr);
|
|
||||||
XMLTest("DeleteNode with null pointer", true, doc.Error() == XML_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check sample xml can be parsed with pedantic mode
|
// Check sample xml can be parsed with pedantic mode
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user