From edc1a2401752c3db30df1b9c6c796c06a8c59cc1 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Mon, 7 Feb 2022 04:39:49 +0100 Subject: [PATCH] Lib: Update alignment of slabs Alignment of slabs should be at least sizeof(ptr) to avoid unaligned pointers in slab structures. Fixme: Use proper way to choose alignment for internal allocators. --- lib/slab.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/slab.c b/lib/slab.c index 6cab6b7b..1d844bab 100644 --- a/lib/slab.c +++ b/lib/slab.c @@ -195,8 +195,8 @@ sl_new(pool *p, uint size) { slab *s = ralloc(p, &sl_class); uint align = sizeof(struct sl_alignment); - if (align < sizeof(int)) - align = sizeof(int); + if (align < sizeof(void *)) + align = sizeof(void *); s->data_size = size; size = (size + align - 1) / align * align; s->obj_size = size;