aboutsummaryrefslogtreecommitdiffstats
path: root/src/node.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/node.c')
-rw-r--r--src/node.c18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/node.c b/src/node.c
index bcf9f56c..c38aee39 100644
--- a/src/node.c
+++ b/src/node.c
@@ -36,37 +36,35 @@ typedef struct {
size_t len;
} SerdConstBuffer;
-static const size_t serd_node_align = sizeof(SerdNode);
-
static SerdNode*
serd_new_from_uri(const SerdURIView uri, const SerdURIView base);
static size_t
serd_node_pad_size(const size_t n_bytes)
{
- const size_t pad = serd_node_align - (n_bytes + 2) % serd_node_align;
+ const size_t pad = sizeof(SerdNode) - (n_bytes + 2) % sizeof(SerdNode);
const size_t size = n_bytes + 2 + pad;
- assert(size % serd_node_align == 0);
+ assert(size % sizeof(SerdNode) == 0);
return size;
}
static const SerdNode*
serd_node_meta_c(const SerdNode* node)
{
- return node + 1 + (serd_node_pad_size(node->n_bytes) / serd_node_align);
+ return node + 1 + (serd_node_pad_size(node->n_bytes) / sizeof(SerdNode));
}
static SerdNode*
serd_node_meta(SerdNode* node)
{
- return node + 1 + (serd_node_pad_size(node->n_bytes) / serd_node_align);
+ return node + 1 + (serd_node_pad_size(node->n_bytes) / sizeof(SerdNode));
}
static const SerdNode*
serd_node_maybe_get_meta_c(const SerdNode* node)
{
return (node->flags & (SERD_HAS_LANGUAGE | SERD_HAS_DATATYPE))
- ? (node + 1 + (serd_node_pad_size(node->n_bytes) / serd_node_align))
+ ? (node + 1 + (serd_node_pad_size(node->n_bytes) / sizeof(SerdNode)))
: NULL;
}
@@ -106,7 +104,7 @@ serd_node_malloc(size_t n_bytes, SerdNodeFlags flags, SerdNodeType type)
node->flags = flags;
node->type = type;
- assert((intptr_t)node % serd_node_align == 0);
+ assert((uintptr_t)node % sizeof(SerdNode) == 0u);
return node;
}
@@ -196,7 +194,7 @@ serd_new_plain_literal_i(const SerdStringView str,
memcpy(serd_node_buffer(node), str.buf, str.len);
node->n_bytes = str.len;
- SerdNode* lang_node = node + 1 + (len / serd_node_align);
+ SerdNode* lang_node = node + 1 + (len / sizeof(SerdNode));
lang_node->type = SERD_LITERAL;
lang_node->n_bytes = lang.len;
memcpy(serd_node_buffer(lang_node), lang.buf, lang.len);
@@ -225,7 +223,7 @@ serd_new_typed_literal_i(const SerdStringView str,
memcpy(serd_node_buffer(node), str.buf, str.len);
node->n_bytes = str.len;
- SerdNode* datatype_node = node + 1 + (len / serd_node_align);
+ SerdNode* datatype_node = node + 1 + (len / sizeof(SerdNode));
datatype_node->n_bytes = datatype_uri.len;
datatype_node->type = SERD_URI;
memcpy(serd_node_buffer(datatype_node), datatype_uri.buf, datatype_uri.len);