aboutsummaryrefslogtreecommitdiffhomepage
path: root/mem.c
diff options
context:
space:
mode:
authorlemon <lsof@mailbox.org>2025-09-17 09:49:22 +0200
committerlemon <lsof@mailbox.org>2025-09-17 09:49:22 +0200
commit960f79fa50009fd1e95a294547e3e46494d49484 (patch)
tree93fbb3bb326f7efb8cfdfb249f0d1b76ef25d3bc /mem.c
parent3d0c49f4eb9e13e00bf12940b53da0f018c0a58c (diff)
alloc changes
Diffstat (limited to 'mem.c')
-rw-r--r--mem.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/mem.c b/mem.c
index 8ed87eb..7faadc6 100644
--- a/mem.c
+++ b/mem.c
@@ -11,6 +11,14 @@
} while (0)
void *
+(xmalloc)(size_t n, const char *f)
+{
+ void *p = malloc(n);
+ if (!p) ALLOCERR(f);
+ return p;
+}
+
+void *
(xcalloc)(size_t n, const char *f)
{
void *p = calloc(n, 1);
@@ -84,7 +92,7 @@ vresize_(void **p, int *pcap, uint *pn, uint siz, uint N)
struct arena *
newarena(uint chunksiz)
{
- struct arena *ar = xcalloc(offsetof(struct arena, mem) + chunksiz);
+ struct arena *ar = xmalloc(offsetof(struct arena, mem) + chunksiz);
assert(chunksiz < 1u<<31 && "toobig");
ar->cap = chunksiz;
ar->dyn = 1;