aboutsummaryrefslogtreecommitdiffstats
path: root/src/node.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-04-09 10:28:59 +0200
committerDavid Robillard <d@drobilla.net>2020-10-27 13:13:58 +0100
commite2d2c7b027ac9ac142ae306d248f2d687df211eb (patch)
treec8326d3deb8b9bb23e2c815d88b917220ef0d85b /src/node.h
parent68b30967872915b93c600e353d2fd6d5fb4987c6 (diff)
downloadserd-e2d2c7b027ac9ac142ae306d248f2d687df211eb.tar.gz
serd-e2d2c7b027ac9ac142ae306d248f2d687df211eb.tar.bz2
serd-e2d2c7b027ac9ac142ae306d248f2d687df211eb.zip
Align nodes with posix_memalign if possible
Diffstat (limited to 'src/node.h')
-rw-r--r--src/node.h8
1 files changed, 8 insertions, 0 deletions
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)
{