aboutsummaryrefslogtreecommitdiffhomepage
path: root/mem.c
diff options
context:
space:
mode:
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;