aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util.c')
-rw-r--r--src/util.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/util.c b/src/util.c
new file mode 100644
index 0000000..022e04b
--- /dev/null
+++ b/src/util.c
@@ -0,0 +1,23 @@
+/*
+ * util.c:
+ *
+ * Copyright (c) 2017 James McKenzie <foss@madingley.org>,
+ * All rights reserved.
+ *
+ */
+
+#include "project.h"
+
+void *
+xmalloc (size_t s)
+{
+ void *ret = malloc (s);
+
+ if (!ret)
+ {
+ fprintf (stderr, "malloc(%lu) failed - aborting\n", s);
+ exit (1);
+ }
+
+ return ret;
+}