From 36e2f27502524155e6475a75ffcab4999fce166a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 24 Feb 2021 21:07:07 -0500 Subject: Align node allocations --- src/node.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/node.c') diff --git a/src/node.c b/src/node.c index 0322dd64..0da9d0ed 100644 --- a/src/node.c +++ b/src/node.c @@ -18,6 +18,7 @@ #include "static_nodes.h" #include "string_utils.h" +#include "system.h" #include "exess/exess.h" #include "serd/serd.h" @@ -97,7 +98,7 @@ SerdNode* serd_node_malloc(size_t n_bytes, SerdNodeFlags flags, SerdNodeType type) { const size_t size = sizeof(SerdNode) + serd_node_pad_size(n_bytes); - SerdNode* node = (SerdNode*)calloc(1, size); + SerdNode* node = (SerdNode*)serd_calloc_aligned(sizeof(SerdNode), size); node->n_bytes = 0; node->flags = flags; @@ -112,7 +113,8 @@ serd_node_set(SerdNode** dst, const SerdNode* src) { const size_t size = serd_node_total_size(src); if (serd_node_total_size(*dst) < size) { - (*dst) = (SerdNode*)realloc(*dst, size); + serd_free_aligned(*dst); + *dst = (SerdNode*)serd_calloc_aligned(sizeof(SerdNode), size); } memcpy(*dst, src, size); @@ -345,7 +347,7 @@ serd_node_copy(const SerdNode* node) } const size_t size = serd_node_total_size(node); - SerdNode* copy = (SerdNode*)calloc(1, size + 3); + SerdNode* copy = (SerdNode*)serd_calloc_aligned(sizeof(SerdNode), size); memcpy(copy, node, size); return copy; @@ -749,5 +751,5 @@ serd_node_flags(const SerdNode* node) void serd_node_free(SerdNode* node) { - free(node); + serd_free_aligned(node); } -- cgit v1.2.1