aboutsummaryrefslogtreecommitdiff
path: root/src/memory.c
diff options
context:
space:
mode:
authorMartin Kagamino Lehoux <martin@lehoux.net>2025-08-22 21:15:31 +0200
committerMartin Kagamino Lehoux <martin@lehoux.net>2025-08-27 11:43:09 +0200
commit07dbb6538ca55e69a33ada6761e749f4ee06affe (patch)
treebe8eaf0a1b3a20aba89a85fe6b614227655e6a39 /src/memory.c
parent911f1fe752173fdfee3f135acd2509c908c7fce2 (diff)
json: Improved parsing performance
Diffstat (limited to 'src/memory.c')
-rw-r--r--src/memory.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/memory.c b/src/memory.c
index 63acb39..62f47e7 100644
--- a/src/memory.c
+++ b/src/memory.c
@@ -22,9 +22,12 @@ void *alloc(Arena *a, size count, size tsize, size align) {
size alloc_size = count * tsize;
assert(beg + alloc_size < a->end);
a->beg = beg + alloc_size;
- return memset(beg, 0, count * tsize);
+ return beg;
}
-void Arena_reset(Arena *a) { a->beg = a->end - a->cap; }
+void Arena_reset(Arena *a) {
+ a->beg = a->end - a->cap;
+ memset(a->beg, 0, a->end - a->beg);
+}
size Arena_get_used(Arena a) { return a.cap - (a.end - a.beg); }