Optimized xml_document::destroy
git-svn-id: http://pugixml.googlecode.com/svn/trunk@402 99668b35-9821-0410-8761-19e4c4f06640
This commit is contained in:
parent
47c23efe62
commit
14bda69d0d
@ -4084,20 +4084,34 @@ namespace pugi
|
|||||||
|
|
||||||
void xml_document::destroy()
|
void xml_document::destroy()
|
||||||
{
|
{
|
||||||
|
// destroy static storage
|
||||||
if (_buffer)
|
if (_buffer)
|
||||||
{
|
{
|
||||||
global_deallocate(_buffer);
|
global_deallocate(_buffer);
|
||||||
_buffer = 0;
|
_buffer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// unoptimized deallocation, for verification purposes
|
// destroy dynamic storage, leave sentinel page and next page (if any)
|
||||||
if (_root)
|
if (_root)
|
||||||
{
|
{
|
||||||
_root->destroy(get_allocator(), sizeof(xml_document_struct));
|
|
||||||
|
|
||||||
assert(_memory.next);
|
assert(_memory.next);
|
||||||
assert(!_memory.next->next);
|
|
||||||
assert(_memory.next->busy_size == 0 && _memory.next->freed_size == 0);
|
// destroy all pages
|
||||||
|
for (xml_memory_page* page = _memory.next->next; page; )
|
||||||
|
{
|
||||||
|
xml_memory_page* next = page->next;
|
||||||
|
|
||||||
|
xml_allocator::deallocate_page(page);
|
||||||
|
|
||||||
|
page = next;
|
||||||
|
}
|
||||||
|
|
||||||
|
// cleanup next page
|
||||||
|
_memory.next->allocator = 0;
|
||||||
|
_memory.next->next = 0;
|
||||||
|
_memory.next->busy_size = _memory.next->freed_size = 0;
|
||||||
|
|
||||||
|
_root = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user