diff options
Diffstat (limited to 'src/stack.h')
-rw-r--r-- | src/stack.h | 8 |
1 files changed, 6 insertions, 2 deletions
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 <assert.h> #include <stdbool.h> #include <stddef.h> @@ -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; |