From e2d2c7b027ac9ac142ae306d248f2d687df211eb Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 9 Apr 2019 10:28:59 +0200 Subject: Align nodes with posix_memalign if possible --- src/node.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/node.h') diff --git a/src/node.h b/src/node.h index db5d25e2..d69d6421 100644 --- a/src/node.h +++ b/src/node.h @@ -28,6 +28,14 @@ struct SerdNodeImpl { SerdNodeType type; /**< Node type */ }; +/* We need nodes aligned to at least size_t so that this is not an unaligned + access. Though it would be possible to make the node header fixed-size and + fit entirely in 64 bits, saving some memory in the process, using weird + types here needs a lot of sketchy casting, particularly since size_t is + universal for string lengths in C. So, we simply suffer the hassle (and + overhead) internally for now to prevent the API from being too weird. */ +static const size_t serd_node_align = sizeof(size_t); + static inline char* serd_node_buffer(SerdNode* node) { -- cgit v1.2.1