From 977aa1d0d29b5b48b31279d7709a7209001ee309 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 21 Mar 2021 17:28:48 +0100 Subject: Force 64 bit alignment of blocks managed by the pool allocator Signed-off-by: David Oberhollenzer --- lib/util/mempool.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/util/mempool.c b/lib/util/mempool.c index dd2d692..57aab4d 100644 --- a/lib/util/mempool.c +++ b/lib/util/mempool.c @@ -14,6 +14,7 @@ #include #define DEF_POOL_SIZE (65536) +#define MEM_ALIGN (8) typedef struct pool_t { struct pool_t *next; @@ -99,6 +100,9 @@ mem_pool_t *mem_pool_create(size_t obj_size) if (mem == NULL) return NULL; + if (obj_size % MEM_ALIGN) + obj_size += MEM_ALIGN - obj_size % MEM_ALIGN; + for (;;) { total = pool_size_from_bitmap_count(count, obj_size); if (total > DEF_POOL_SIZE) -- cgit v1.2.3