1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
/* Copyright 2016 Luke Shumaker */ #include <stdlib.h> #include <error.h> #include <errno.h> #include "util.h" void *xrealloc(void *ptr, size_t size) { void *ret = realloc(ptr, size); if (ret == NULL) { if (ptr==NULL) error(1, errno, "Could not allocate memory"); else error(1, errno, "Could not re-allocate memory"); } return ret; }