From 701e2d55e6cb8f8566c868af8f3e9ffe4244975c Mon Sep 17 00:00:00 2001 From: Dominic Szablewski Date: Mon, 4 Sep 2023 13:58:43 +0200 Subject: [PATCH] Fix 8 byte alignment in temp allocator; close #68 --- src/mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mem.c b/src/mem.c index d25baf5..3316d73 100644 --- a/src/mem.c +++ b/src/mem.c @@ -46,7 +46,7 @@ void mem_reset(void *p) { // and aftewards free A then B. void *mem_temp_alloc(uint32_t size) { - size = ((size >> 3) + 7) << 3; // allign to 8 bytes + size = ((size + 7) >> 3) << 3; // allign to 8 bytes error_if(bump_len + temp_len + size >= MEM_HUNK_BYTES, "Failed to allocate %d bytes in temp mem", size); error_if(temp_objects_len >= MEM_TEMP_OBJECTS_MAX, "MEM_TEMP_OBJECTS_MAX reached");