diff options
Diffstat (limited to 'src/util.c')
-rw-r--r-- | src/util.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -11,3 +11,25 @@ must_malloc(size_t size) exit(EXIT_ABNORMAL); } } + +void * +must_calloc(size_t nmemb, size_t size) +{ + void *ret = calloc(nmemb, size); + if (ret == NULL) { + fprintf(stderr, "out of memory\n"); + exit(EXIT_ABNORMAL); + } + return ret; +} + +void * +must_realloc(void *ptr, size_t size) +{ + void *ret = realloc(ptr, size); + if (ret == NULL) { + fprintf(stderr, "out of memory\n"); + exit(EXIT_ABNORMAL); + } + return ret; +} |