summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'util.c')
-rw-r--r--util.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/util.c b/util.c
new file mode 100644
index 0000000..22b6dc6
--- /dev/null
+++ b/util.c
@@ -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;
+}