]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
Lib: Update alignment of slabs
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Mon, 7 Feb 2022 03:39:49 +0000 (04:39 +0100)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Mon, 7 Feb 2022 03:39:49 +0000 (04:39 +0100)
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

index 6cab6b7b525c44d75222675c70a0c52b04a19ec6..1d844babd1b1cd4b4307a2042c70101b25c8e1e3 100644 (file)
@@ -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;