From bd7a8fa4bfa361b06cdbb497021545f0f7ba66ac Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Sat, 25 Jul 2015 17:08:19 -0400 Subject: XPath: Increase memory block alignment to 8 bytes To be more precise, the memory block is now aligned to be able to reliably allocate objects with both double and pointer fields. If there is a platform with a 4-byte double and a 4-byte pointer, the memory block alignment there will stay the same after this change. Fixes #48. --- src/pugixml.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/pugixml.cpp') diff --git a/src/pugixml.cpp b/src/pugixml.cpp index 5f8dbdb..b3195f7 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -7267,14 +7267,18 @@ PUGI__NS_BEGIN #endif ; - static const uintptr_t xpath_memory_block_alignment = sizeof(void*); + static const uintptr_t xpath_memory_block_alignment = sizeof(double) > sizeof(void*) ? sizeof(double) : sizeof(void*); struct xpath_memory_block { xpath_memory_block* next; size_t capacity; - char data[xpath_memory_page_size]; + union + { + char data[xpath_memory_page_size]; + double alignment; + }; }; class xpath_allocator -- cgit v1.2.3