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/stack.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/stack.h') diff --git a/src/stack.h b/src/stack.h index f6d33f51..0eae1b75 100644 --- a/src/stack.h +++ b/src/stack.h @@ -17,6 +17,8 @@ #ifndef SERD_STACK_H #define SERD_STACK_H +#include "system.h" + #include #include #include @@ -37,10 +39,12 @@ typedef struct { #define SERD_STACK_BOTTOM sizeof(void*) static inline SerdStack -serd_stack_new(size_t size) +serd_stack_new(size_t size, size_t align) { + const size_t aligned_size = (size + (align - 1)) / align * align; + SerdStack stack; - stack.buf = (char*)calloc(size, 1); + stack.buf = (char*)serd_calloc_aligned(align, aligned_size); stack.buf_size = size; stack.size = SERD_STACK_BOTTOM; return stack; -- cgit v1.2.1