diff options
author | David Robillard <d@drobilla.net> | 2021-02-24 21:07:07 -0500 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2021-03-08 23:23:05 -0500 |
commit | 36e2f27502524155e6475a75ffcab4999fce166a (patch) | |
tree | c193ccab896fa63a48e0dba5eecfccfc9ec46a2b /src/node.c | |
parent | 02507b57fae1e29572a11be8894b7dde9048da5d (diff) | |
download | serd-36e2f27502524155e6475a75ffcab4999fce166a.tar.gz serd-36e2f27502524155e6475a75ffcab4999fce166a.tar.bz2 serd-36e2f27502524155e6475a75ffcab4999fce166a.zip |
Align node allocations
Diffstat (limited to 'src/node.c')
-rw-r--r-- | src/node.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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); } |