diff options
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -0,0 +1,17 @@ +#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; +} |