#include #include #include #include void die(const char *msg) { fprintf(stderr, "panic: "); perror(msg); exit(EXIT_FAILURE); } void *safe_calloc(unsigned int i, size_t size) { void *x = calloc(i, size); if (x == NULL) { die("abort: calloc()"); } return x; } void *safe_realloc(void *x, size_t size) { void *p = realloc(x, size); if (x == NULL) { die("abort: realloc()"); } return p; } void alloc_zero(void *ptr, size_t size) { memset(ptr, 0, size); }