diff options
| author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-01-19 11:21:49 +0000 | 
|---|---|---|
| committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-01-19 11:21:49 +0000 | 
| commit | 0949bd80b644666e23aa91125ebad16e4e3b20de (patch) | |
| tree | 6e8cfce3fd8ca2a7b3ffcd28c26e68223f533076 /src/pugixml.cpp | |
| parent | bf160df1254f650f9d541ee7a8f0ab62e3c8ac16 (diff) | |
Added invalidate_document_order, now detaching deleted nodes and setting name/value to 0 after deleting (less bugs/debugging confusion)
git-svn-id: http://pugixml.googlecode.com/svn/trunk@110 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'src/pugixml.cpp')
| -rw-r--r-- | src/pugixml.cpp | 28 | 
1 files changed, 22 insertions, 6 deletions
| diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 4ea08a9..6d8cff5 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -140,8 +140,19 @@ namespace pugi  		void destroy()
  		{
 -			if (!name_insitu) delete[] name;
 -			if (!value_insitu) delete[] value;
 +		    parent = 0;
 +		    
 +			if (!name_insitu)
 +			{
 +			    delete[] name;
 +			    name = 0;
 +			}
 +			
 +			if (!value_insitu)
 +			{
 +			    delete[] value;
 +			    value = 0;
 +            }
  			for (xml_attribute_struct* attr = first_attribute; attr; attr = attr->next_attribute)
  				attr->destroy();
 @@ -2584,7 +2595,7 @@ namespace pugi  		return empty() ? 0 : _root->document_order;
  	}
 -	void xml_node::precompute_document_order_impl()
 +	void xml_node::precompute_document_order_impl(unsigned int mask)
  	{
  		if (type() != node_document) return;
 @@ -2593,10 +2604,10 @@ namespace pugi  		for (;;)
  		{
 -			cur._root->document_order = current++;
 +			cur._root->document_order = mask & current++;
  			for (xml_attribute a = cur.first_attribute(); a; a = a.next_attribute())
 -				a._attr->document_order = current++;
 +				a._attr->document_order = mask & current++;
  			if (cur.first_child())
  				cur = cur.first_child();
 @@ -2976,9 +2987,14 @@ namespace pugi  	void xml_document::precompute_document_order()
  	{
 -		precompute_document_order_impl();
 +		precompute_document_order_impl(~0u);
  	}
 +    void xml_document::invalidate_document_order()
 +    {
 +        precompute_document_order_impl(0);
 +    }
 +    
  #ifndef PUGIXML_NO_STL
  	std::string as_utf8(const wchar_t* str)
  	{
 | 
