summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-07-25 17:08:19 -0400
committerArseny Kapoulkine <arseny.kapoulkine@gmail.com>2015-07-25 17:08:19 -0400
commitbd7a8fa4bfa361b06cdbb497021545f0f7ba66ac (patch)
tree9d7437e2b587282d14ecceed164d0c0b2a3e9dce /src
parente8fdd1303c6c28ebd2183a77b507c26a570fe4f5 (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.cpp8
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