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.
This commit is contained in:
Ondrej Zajicek (work) 2022-02-07 04:39:49 +01:00
parent 53a2540687
commit edc1a24017

View file

@ -195,8 +195,8 @@ sl_new(pool *p, uint size)
{ {
slab *s = ralloc(p, &sl_class); slab *s = ralloc(p, &sl_class);
uint align = sizeof(struct sl_alignment); uint align = sizeof(struct sl_alignment);
if (align < sizeof(int)) if (align < sizeof(void *))
align = sizeof(int); align = sizeof(void *);
s->data_size = size; s->data_size = size;
size = (size + align - 1) / align * align; size = (size + align - 1) / align * align;
s->obj_size = size; s->obj_size = size;