aboutsummaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c20
1 files changed, 10 insertions, 10 deletions
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); }