From 9bc8baf973e24bcd6e1b8ffb09ebc84165ac2d8e Mon Sep 17 00:00:00 2001 From: dzy Date: Wed, 24 Jul 2024 20:27:28 +0800 Subject: [PATCH] Fix first buffer alignment --- tinyalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tinyalloc.c b/tinyalloc.c index eb9fa3f..34e1854 100644 --- a/tinyalloc.c +++ b/tinyalloc.c @@ -121,7 +121,7 @@ bool ta_init(const void *base, const void *limit, const size_t heap_blocks, cons heap->free = NULL; heap->used = NULL; heap->fresh = (Block *)(heap + 1); - heap->top = (size_t)(heap->fresh + heap_blocks); + heap->top = (((size_t)(heap->fresh + heap_blocks)) + heap_alignment - 1) & -heap_alignment; Block *block = heap->fresh; size_t i = heap_max_blocks - 1;