diff options
author | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-07-25 17:08:19 -0400 |
---|---|---|
committer | Arseny Kapoulkine <arseny.kapoulkine@gmail.com> | 2015-07-25 17:08:19 -0400 |
commit | bd7a8fa4bfa361b06cdbb497021545f0f7ba66ac (patch) | |
tree | 9d7437e2b587282d14ecceed164d0c0b2a3e9dce /src | |
parent | e8fdd1303c6c28ebd2183a77b507c26a570fe4f5 (diff) |
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.
Diffstat (limited to 'src')
-rw-r--r-- | src/pugixml.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
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 |