commit c2b5067c010580f1e85c10f15ab3476494837024
parent 318c2a4f969edc351e6275448a03e41bf3524a22
Author: MikoĊaj Lenczewski <mblenczewski@gmail.com>
Date: Sun, 12 Feb 2023 02:46:05 +0000
Assert that size given to mem_pool_alloc() conforms to given alignment
Diffstat:
1 file changed, 1 insertion(+), 0 deletions(-)
diff --git a/include/utils.h b/include/utils.h
@@ -144,6 +144,7 @@ mem_pool_alloc(struct mem_pool *self, u64 alignment, u64 size) {
assert(self);
assert(alignment);
assert(alignment == 1 || alignment % 2 == 0);
+ assert(size % alignment == 0);
u64 alignment_off = alignment - 1;
u64 aligned_len = (self->len + alignment_off) & ~alignment_off;