From 95428c41f0ee3ac108cf1a4acfaa67157ad954dc Mon Sep 17 00:00:00 2001 From: Sadeep Madurange Date: Sun, 24 May 2026 18:00:38 +0800 Subject: Build DOM. --- mem.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'mem.h') diff --git a/mem.h b/mem.h index 032740c..2cdb36e 100644 --- a/mem.h +++ b/mem.h @@ -5,6 +5,7 @@ #include #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; -- cgit v1.2.3