From 0949bd80b644666e23aa91125ebad16e4e3b20de Mon Sep 17 00:00:00 2001 From: "arseny.kapoulkine" Date: Mon, 19 Jan 2009 11:21:49 +0000 Subject: 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 --- src/pugixml.cpp | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'src/pugixml.cpp') 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) { -- cgit v1.2.3