diff options
| author | Sadeep Madurange <sadeep@asciimx.com> | 2026-05-24 18:00:38 +0800 |
|---|---|---|
| committer | Sadeep Madurange <sadeep@asciimx.com> | 2026-05-28 15:34:29 +0800 |
| commit | 95428c41f0ee3ac108cf1a4acfaa67157ad954dc (patch) | |
| tree | 8565027758cd931f49ebe78738fb41126254b253 /mem.h | |
| parent | 7aea09077aad335ac32bfd9858ded60ffd4d8a5b (diff) | |
| download | glacier-95428c41f0ee3ac108cf1a4acfaa67157ad954dc.tar.gz | |
Build DOM.
Diffstat (limited to 'mem.h')
| -rw-r--r-- | mem.h | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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; |
