kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit db4f6cf01fd48530140f03276b87c8767f25dfa9
parent 0b92afe53d030f1f1c33ad092f3f0d1d6f4a7455
Author: Joris Vink <joris@coders.se>
Date:   Thu, 28 Jul 2016 14:52:15 +0200

align pointers from kore_malloc() properly.

Diffstat:
src/mem.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 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;