diff options
Diffstat (limited to 'src/dt/common.h')
-rw-r--r-- | src/dt/common.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/dt/common.h b/src/dt/common.h index 6633be6..cbe17ce 100644 --- a/src/dt/common.h +++ b/src/dt/common.h @@ -85,7 +85,15 @@ int dev_printf(int level, const struct device_d *dev, const char *format, ...) static inline void *xzalloc(size_t size) { - return calloc(1, size); + void * buf = calloc(1, size); + if (!buf || errno == ENOMEM) { + /* although the glibc variant of calloc sets errno, not all + * variants do, but should still return NULL. */ + errno = ENOMEM; + perror("xzalloc"); + exit(1); + } + return buf; } static inline void *xmalloc(size_t size) |