From db4f6cf01fd48530140f03276b87c8767f25dfa9 Mon Sep 17 00:00:00 2001 From: Joris Vink Date: Thu, 28 Jul 2016 14:52:15 +0200 Subject: [PATCH] align pointers from kore_malloc() properly. --- src/mem.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mem.c b/src/mem.c index b990ccb..b699aa3 100644 --- a/src/mem.c +++ b/src/mem.c @@ -25,6 +25,7 @@ #define KORE_MEM_BLOCK_SIZE_MAX 8192 #define KORE_MEM_BLOCK_PREALLOC 128 +#define KORE_MEM_ALIGN (sizeof(size_t)) #define KORE_MEM_MAGIC 0xd0d0 #define KORE_MEMSIZE(x) \ (*(size_t *)((u_int8_t *)x - sizeof(size_t))) @@ -58,7 +59,10 @@ kore_mem_init(void) fatal("kore_mem_init: snprintf"); elm = (KORE_MEM_BLOCK_PREALLOC * 1024) / size; - mlen = sizeof(size_t) + size + sizeof(struct meminfo); + mlen = sizeof(size_t) + size + + sizeof(struct meminfo) + KORE_MEM_ALIGN; + mlen = mlen & ~(KORE_MEM_ALIGN - 1); + kore_pool_init(&blocks[i].pool, name, mlen, elm); size = size << 1;