From 0be32393e54bed6bbf5890edba72b8808d276289 Mon Sep 17 00:00:00 2001 From: Martin Kagamino Lehoux Date: Mon, 21 Jul 2025 17:06:53 +0200 Subject: format --- memory.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'memory.c') diff --git a/memory.c b/memory.c index f11af57..7fa3e1d 100644 --- a/memory.c +++ b/memory.c @@ -7,21 +7,21 @@ #include "types.h" Arena Arena_new(size cap) { - Arena a = {0}; - a.cap = cap; - a.beg = malloc(cap); - a.end = a.beg ? a.beg + cap : 0; - return a; + Arena a = {0}; + a.cap = cap; + a.beg = malloc(cap); + a.end = a.beg ? a.beg + cap : 0; + return a; } // Magic to allow optimisation __attribute((malloc, alloc_size(2, 4), // alloc_align(3))) void *alloc(Arena *a, size count, size tsize, int align) { - int padding = -(uptr)a->beg & (align - 1); - assert(count < (a->end - a->beg - padding) / tsize); - void *cursor = a->beg + padding; - a->beg += padding + count * tsize; - return memset(cursor, 0, count * tsize); + int padding = -(uptr)a->beg & (align - 1); + assert(count < (a->end - a->beg - padding) / tsize); + void *cursor = a->beg + padding; + a->beg += padding + count * tsize; + return memset(cursor, 0, count * tsize); } int Arena_get_used(Arena a) { return a.cap - (a.end - a.beg); } -- cgit v1.3