aboutsummaryrefslogtreecommitdiff
path: root/memory.c
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-07-22 08:59:24 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-07-22 08:59:24 +0200
commit13fdee74dc28f0b068503843c6e14071a7c339f2 (patch)
tree323f35e351394c89faeaf61cccad716ba4e4fb1a /memory.c
parente02bfc1854effe0bb55ea6d4320e2b1902eaeae3 (diff)
feat: More integer types
Diffstat (limited to 'memory.c')
-rw-r--r--memory.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/memory.c b/memory.c
index 7fa3e1d..83757b6 100644
--- a/memory.c
+++ b/memory.c
@@ -1,5 +1,6 @@
#include <assert.h>
#include <stdint.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -16,12 +17,12 @@ Arena Arena_new(size cap) {
// 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);
+void *alloc(Arena *a, size count, size tsize, size align) {
+ size 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); }
+size Arena_get_used(Arena a) { return a.cap - (a.end - a.beg); }