integrated attributes into the placement new
diff --git a/tinyxml2.cpp b/tinyxml2.cpp
index 829ef17..fd11c27 100644
--- a/tinyxml2.cpp
+++ b/tinyxml2.cpp
@@ -17,6 +17,9 @@
 static const char SINGLE_QUOTE			= '\'';

 static const char DOUBLE_QUOTE			= '\"';

 

+#define DELETE_NODE( node ) { MemPool* pool = node->memPool; node->~XMLNode(); pool->Free( node ); }

+#define DELETE_ATTRIBUTE( attrib ) { MemPool* pool = attrib->memPool; attrib->~XMLAttribute(); pool->Free( attrib ); }

+

 struct Entity {

 	const char* pattern;

 	int length;

@@ -260,12 +263,7 @@
 		XMLNode* node = firstChild;

 		Unlink( node );

 		

-		//delete node;

-		// placement new!

-		MemPool* pool = node->memPool;

-		node->~XMLNode();

-		pool->Free( node );

-		// fixme: memory never free'd. 

+		DELETE_NODE( node );

 	}

 	firstChild = lastChild = 0;

 }

@@ -347,10 +345,7 @@
 			p = node->ParseDeep( p );

 			// FIXME: is it the correct closing element?

 			if ( node->IsClosingElement() ) {

-				//delete node;

-				MemPool* pool = node->memPool;

-				node->~XMLNode();	// fixme linked list memory not free

-				pool->Free( node );

+				DELETE_NODE( node );

 				return p;

 			}

 			this->InsertEndChild( node );

@@ -444,7 +439,7 @@
 	XMLAttribute* attribute = rootAttribute;

 	while( attribute ) {

 		XMLAttribute* next = attribute->next;

-		delete attribute;

+		DELETE_ATTRIBUTE( attribute );

 		attribute = next;

 	}

 }

@@ -465,11 +460,12 @@
 

 		// attribute.

 		if ( XMLBase::IsAlpha( *p ) ) {

-			XMLAttribute* attrib = new XMLAttribute( this );

+			XMLAttribute* attrib = new (document->attributePool.Alloc() ) XMLAttribute( this );

+			attrib->memPool = &document->attributePool;

 

 			p = attrib->ParseDeep( p );

 			if ( !p ) {

-				delete attrib;

+				DELETE_ATTRIBUTE( attrib );

 				document->SetError( XMLDocument::ERROR_PARSING_ATTRIBUTE, start, p );

 				return 0;

 			}

diff --git a/tinyxml2.h b/tinyxml2.h
index f024647..2a6e344 100644
--- a/tinyxml2.h
+++ b/tinyxml2.h
@@ -206,8 +206,8 @@
 		root = chunk;

 	}

 	void Trace( const char* name ) {

-		printf( "Mempool %s watermark=%d current=%d size=%d nAlloc=%d blocks=%d\n",

-				 name, maxAllocs, currentAllocs, SIZE, nAllocs, blockPtrs.Size() );

+		printf( "Mempool %s watermark=%d [%dk] current=%d size=%d nAlloc=%d blocks=%d\n",

+				 name, maxAllocs, maxAllocs*SIZE/1024, currentAllocs, SIZE, nAllocs, blockPtrs.Size() );

 	}

 

 private:

@@ -419,6 +419,7 @@
 	StrPair name;

 	StrPair value;

 	XMLAttribute* next;

+	MemPool* memPool;

 };

 

 

diff --git a/xmltest.cpp b/xmltest.cpp
index bef0216..243f0fa 100644
--- a/xmltest.cpp
+++ b/xmltest.cpp
@@ -28,19 +28,19 @@
 	}

 #endif

 	{

-		static const char* test[] = {	//"<element />",

-									    //"<element></element>",

-										//"<element><subelement/></element>",

-									    //"<element><subelement></subelement></element>",

-									   // "<element><subelement><subsub/></subelement></element>",

-									    //"<!--comment beside elements--><element><subelement></subelement></element>",

-									    //"<!--comment beside elements, this time with spaces-->  \n <element>  <subelement> \n </subelement> </element>",

-									    //"<element attrib1='foo' attrib2=\"bar\" ></element>",

-									    //"<element attrib1='foo' attrib2=\"bar\" ><subelement attrib3='yeehaa' /></element>",

-										//"<element>Text inside element.</element>",

-										//"<element><b></b></element>",

-										//"<element>Text inside and <b>bolded</b> in the element.</element>",

-										//"<outer><element>Text inside and <b>bolded</b> in the element.</element></outer>",

+		static const char* test[] = {	"<element />",

+									    "<element></element>",

+										"<element><subelement/></element>",

+									    "<element><subelement></subelement></element>",

+									    "<element><subelement><subsub/></subelement></element>",

+									    "<!--comment beside elements--><element><subelement></subelement></element>",

+									    "<!--comment beside elements, this time with spaces-->  \n <element>  <subelement> \n </subelement> </element>",

+									    "<element attrib1='foo' attrib2=\"bar\" ></element>",

+									    "<element attrib1='foo' attrib2=\"bar\" ><subelement attrib3='yeehaa' /></element>",

+										"<element>Text inside element.</element>",

+										"<element><b></b></element>",

+										"<element>Text inside and <b>bolded</b> in the element.</element>",

+										"<outer><element>Text inside and <b>bolded</b> in the element.</element></outer>",

 										"<element>This &amp; That.</element>",

 										"<element attrib='This&lt;That' />",

 										0