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/stack.h | |
parent | 02507b57fae1e29572a11be8894b7dde9048da5d (diff) | |
download | serd-36e2f27502524155e6475a75ffcab4999fce166a.tar.gz serd-36e2f27502524155e6475a75ffcab4999fce166a.tar.bz2 serd-36e2f27502524155e6475a75ffcab4999fce166a.zip |
Align node allocations
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; |