From: Ondrej Zajicek (work) Date: Mon, 7 Feb 2022 03:39:49 +0000 (+0100) Subject: Lib: Update alignment of slabs X-Git-Tag: v2.0.9~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=edc1a2401752c3db30df1b9c6c796c06a8c59cc1;p=thirdparty%2Fbird.git 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. --- diff --git a/lib/slab.c b/lib/slab.c index 6cab6b7b5..1d844babd 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;