mirror of https://github.com/AxioDL/tinyxml2.git
fix issue 184. clean up xcode project.
This commit is contained in:
parent
d211bb1351
commit
f07b952296
35
tinyxml2.cpp
35
tinyxml2.cpp
|
@ -1622,9 +1622,21 @@ XMLDocument::XMLDocument( bool processEntities, Whitespace whitespace ) :
|
||||||
|
|
||||||
|
|
||||||
XMLDocument::~XMLDocument()
|
XMLDocument::~XMLDocument()
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void XMLDocument::Clear()
|
||||||
{
|
{
|
||||||
DeleteChildren();
|
DeleteChildren();
|
||||||
|
|
||||||
|
_errorID = XML_NO_ERROR;
|
||||||
|
_errorStr1 = 0;
|
||||||
|
_errorStr2 = 0;
|
||||||
|
|
||||||
delete [] _charBuffer;
|
delete [] _charBuffer;
|
||||||
|
_charBuffer = 0;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
_textPool.Trace( "text" );
|
_textPool.Trace( "text" );
|
||||||
|
@ -1644,19 +1656,6 @@ XMLDocument::~XMLDocument()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XMLDocument::Clear()
|
|
||||||
{
|
|
||||||
DeleteChildren();
|
|
||||||
|
|
||||||
_errorID = XML_NO_ERROR;
|
|
||||||
_errorStr1 = 0;
|
|
||||||
_errorStr2 = 0;
|
|
||||||
|
|
||||||
delete [] _charBuffer;
|
|
||||||
_charBuffer = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
XMLElement* XMLDocument::NewElement( const char* name )
|
XMLElement* XMLDocument::NewElement( const char* name )
|
||||||
{
|
{
|
||||||
XMLElement* ele = new (_elementPool.Alloc()) XMLElement( this );
|
XMLElement* ele = new (_elementPool.Alloc()) XMLElement( this );
|
||||||
|
@ -1821,6 +1820,16 @@ XMLError XMLDocument::Parse( const char* p, size_t len )
|
||||||
|
|
||||||
ptrdiff_t delta = p - start; // skip initial whitespace, BOM, etc.
|
ptrdiff_t delta = p - start; // skip initial whitespace, BOM, etc.
|
||||||
ParseDeep( _charBuffer+delta, 0 );
|
ParseDeep( _charBuffer+delta, 0 );
|
||||||
|
if (_errorID) {
|
||||||
|
// clean up now essentially dangling memory.
|
||||||
|
// and the parse fail can put objects in the
|
||||||
|
// pools that are dead and inaccessible.
|
||||||
|
DeleteChildren();
|
||||||
|
_elementPool.Clear();
|
||||||
|
_attributePool.Clear();
|
||||||
|
_textPool.Clear();
|
||||||
|
_commentPool.Clear();
|
||||||
|
}
|
||||||
return _errorID;
|
return _errorID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
18
tinyxml2.h
18
tinyxml2.h
|
@ -317,6 +317,7 @@ public:
|
||||||
virtual void* Alloc() = 0;
|
virtual void* Alloc() = 0;
|
||||||
virtual void Free( void* ) = 0;
|
virtual void Free( void* ) = 0;
|
||||||
virtual void SetTracked() = 0;
|
virtual void SetTracked() = 0;
|
||||||
|
virtual void Clear() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -329,10 +330,20 @@ class MemPoolT : public MemPool
|
||||||
public:
|
public:
|
||||||
MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
|
MemPoolT() : _root(0), _currentAllocs(0), _nAllocs(0), _maxAllocs(0), _nUntracked(0) {}
|
||||||
~MemPoolT() {
|
~MemPoolT() {
|
||||||
// Delete the blocks.
|
Clear();
|
||||||
for( int i=0; i<_blockPtrs.Size(); ++i ) {
|
|
||||||
delete _blockPtrs[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Clear() {
|
||||||
|
// Delete the blocks.
|
||||||
|
while( !_blockPtrs.Empty()) {
|
||||||
|
Block* b = _blockPtrs.Pop();
|
||||||
|
delete b;
|
||||||
|
}
|
||||||
|
_root = 0;
|
||||||
|
_currentAllocs = 0;
|
||||||
|
_nAllocs = 0;
|
||||||
|
_maxAllocs = 0;
|
||||||
|
_nUntracked = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int ItemSize() const {
|
virtual int ItemSize() const {
|
||||||
|
@ -365,6 +376,7 @@ public:
|
||||||
_nUntracked++;
|
_nUntracked++;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Free( void* mem ) {
|
virtual void Free( void* mem ) {
|
||||||
if ( !mem ) {
|
if ( !mem ) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -96,6 +96,9 @@
|
||||||
/* Begin PBXProject section */
|
/* Begin PBXProject section */
|
||||||
037AE058151CCC5200E0F29F /* Project object */ = {
|
037AE058151CCC5200E0F29F /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
|
attributes = {
|
||||||
|
LastUpgradeCheck = 0610;
|
||||||
|
};
|
||||||
buildConfigurationList = 037AE05B151CCC5200E0F29F /* Build configuration list for PBXProject "tinyxml2" */;
|
buildConfigurationList = 037AE05B151CCC5200E0F29F /* Build configuration list for PBXProject "tinyxml2" */;
|
||||||
compatibilityVersion = "Xcode 3.2";
|
compatibilityVersion = "Xcode 3.2";
|
||||||
developmentRegion = English;
|
developmentRegion = English;
|
||||||
|
@ -134,6 +137,8 @@
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CONFIGURATION_BUILD_DIR = "$(SYMROOT)/Debug";
|
CONFIGURATION_BUILD_DIR = "$(SYMROOT)/Debug";
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
|
"GCC_PREPROCESSOR_DEFINITIONS[arch=*]" = DEBUG;
|
||||||
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
SYMROOT = build;
|
SYMROOT = build;
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
|
@ -156,6 +161,7 @@
|
||||||
GCC_MODEL_TUNING = G5;
|
GCC_MODEL_TUNING = G5;
|
||||||
GCC_OPTIMIZATION_LEVEL = 0;
|
GCC_OPTIMIZATION_LEVEL = 0;
|
||||||
INSTALL_PATH = /usr/local/bin;
|
INSTALL_PATH = /usr/local/bin;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = "";
|
||||||
PREBINDING = NO;
|
PREBINDING = NO;
|
||||||
PRODUCT_NAME = xmltest;
|
PRODUCT_NAME = xmltest;
|
||||||
};
|
};
|
||||||
|
@ -171,6 +177,7 @@
|
||||||
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
GCC_ENABLE_FIX_AND_CONTINUE = NO;
|
||||||
GCC_MODEL_TUNING = G5;
|
GCC_MODEL_TUNING = G5;
|
||||||
INSTALL_PATH = /usr/local/bin;
|
INSTALL_PATH = /usr/local/bin;
|
||||||
|
MACOSX_DEPLOYMENT_TARGET = "";
|
||||||
PREBINDING = NO;
|
PREBINDING = NO;
|
||||||
PRODUCT_NAME = tinyxml2;
|
PRODUCT_NAME = tinyxml2;
|
||||||
ZERO_LINK = NO;
|
ZERO_LINK = NO;
|
||||||
|
|
15
xmltest.cpp
15
xmltest.cpp
|
@ -1364,6 +1364,21 @@ int main( int argc, const char ** argv )
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
{
|
||||||
|
// Issue #184
|
||||||
|
// If it doesn't assert, it passes. Caused by objects
|
||||||
|
// getting created during parsing which are then
|
||||||
|
// inaccessible in the memory pools.
|
||||||
|
{
|
||||||
|
XMLDocument doc;
|
||||||
|
doc.Parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?><test>");
|
||||||
|
}
|
||||||
|
{
|
||||||
|
XMLDocument doc;
|
||||||
|
doc.Parse("<?xml version=\"1.0\" encoding=\"UTF-8\"?><test>");
|
||||||
|
doc.Clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------- Performance tracking --------------
|
// ----------- Performance tracking --------------
|
||||||
|
|
Loading…
Reference in New Issue