fix incorrect assert on unused memory
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 538717a..fa91b5d 100755
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -669,6 +669,7 @@
addThis->_next = 0;
}
addThis->_parent = this;
+ addThis->_memPool->SetTracked();
return addThis;
}
@@ -693,6 +694,7 @@
addThis->_next = 0;
}
addThis->_parent = this;
+ addThis->_memPool->SetTracked();
return addThis;
}
@@ -713,6 +715,7 @@
afterThis->_next->_prev = addThis;
afterThis->_next = addThis;
addThis->_parent = this;
+ addThis->_memPool->SetTracked();
return addThis;
}
@@ -814,6 +817,7 @@
if ( parentEnd ) {
*parentEnd = static_cast<XMLElement*>(node)->_value;
}
+ node->_memPool->SetTracked(); // created and then immediately deleted.
DELETE_NODE( node );
return p;
}
@@ -1314,6 +1318,7 @@
_rootAttribute = attrib;
}
attrib->SetName( name );
+ attrib->_memPool->SetTracked(); // always created and linked.
}
return attrib;
}
@@ -1355,6 +1360,7 @@
if ( XMLUtil::IsAlpha( *p ) ) {
XMLAttribute* attrib = new (_document->_attributePool.Alloc() ) XMLAttribute();
attrib->_memPool = &_document->_attributePool;
+ attrib->_memPool->SetTracked();
p = attrib->ParseDeep( p, _document->ProcessEntities() );
if ( !p || Attribute( attrib->Name() ) ) {
@@ -1508,10 +1514,14 @@
attributePool.Trace( "attribute" );
#endif
- TIXMLASSERT( _textPool.CurrentAllocs() == 0 );
- TIXMLASSERT( _elementPool.CurrentAllocs() == 0 );
- TIXMLASSERT( _commentPool.CurrentAllocs() == 0 );
- TIXMLASSERT( _attributePool.CurrentAllocs() == 0 );
+#ifdef DEBUG
+ if ( Error() == false ) {
+ TIXMLASSERT( _elementPool.CurrentAllocs() == _elementPool.Untracked() );
+ TIXMLASSERT( _attributePool.CurrentAllocs() == _attributePool.Untracked() );
+ TIXMLASSERT( _textPool.CurrentAllocs() == _textPool.Untracked() );
+ TIXMLASSERT( _commentPool.CurrentAllocs() == _commentPool.Untracked() );
+ }
+#endif
}