summaryrefslogtreecommitdiffstats
path: root/mem.h
diff options
context:
space:
mode:
authorSadeep Madurange <sadeep@asciimx.com>2026-05-24 18:00:38 +0800
committerSadeep Madurange <sadeep@asciimx.com>2026-05-28 15:34:29 +0800
commit95428c41f0ee3ac108cf1a4acfaa67157ad954dc (patch)
tree8565027758cd931f49ebe78738fb41126254b253 /mem.h
parent7aea09077aad335ac32bfd9858ded60ffd4d8a5b (diff)
downloadglacier-95428c41f0ee3ac108cf1a4acfaa67157ad954dc.tar.gz
Build DOM.
Diffstat (limited to 'mem.h')
-rw-r--r--mem.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/mem.h b/mem.h
index 032740c..2cdb36e 100644
--- a/mem.h
+++ b/mem.h
@@ -5,6 +5,7 @@
#include <stdlib.h>
#define MALLOC(s) xmalloc((s), __FILE__, __LINE__)
+#define CALLOC(n, s) xcalloc((n), (s), __FILE__, __LINE__)
#define REALLOC(p, s) xrealloc((p), (s), __FILE__, __LINE__)
static inline void *xmalloc(size_t s, const char *file, int line)
@@ -16,6 +17,15 @@ static inline void *xmalloc(size_t s, const char *file, int line)
return p;
}
+static inline void *xcalloc(size_t n, size_t s, const char *file, int line)
+{
+ void *p;
+
+ if (!(p = calloc(n, s)))
+ err(1, "%s:%d: calloc", file, line);
+ return p;
+}
+
static inline void *xrealloc(void *ptr, size_t s, const char *file, int line)
{
void *p;