Move compact hash table pointer setup to xml_document

This keeps all code that creates document/allocator/page structures together.
This commit is contained in:
Arseny Kapoulkine 2016-11-07 19:29:52 -08:00
parent 9bc497267b
commit e4c43a0aa2

View file

@ -1119,9 +1119,6 @@ PUGI__NS_BEGIN
{
xml_document_struct(xml_memory_page* page): xml_node_struct(page, node_document), xml_allocator(page), buffer(0), extra_buffers(0)
{
#ifdef PUGIXML_COMPACT
_hash = &hash;
#endif
}
const char_t* buffer;
@ -6861,6 +6858,11 @@ namespace pugi
// setup sentinel page
page->allocator = static_cast<impl::xml_document_struct*>(_root);
// setup hash table pointer in allocator
#ifdef PUGIXML_COMPACT
page->allocator->_hash = &static_cast<impl::xml_document_struct*>(_root)->hash;
#endif
// verify the document allocation
assert(reinterpret_cast<char*>(_root) + sizeof(impl::xml_document_struct) <= _memory + sizeof(_memory));
}