aboutsummaryrefslogtreecommitdiffstats
path: root/xlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlib.c')
-rw-r--r--xlib.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/xlib.c b/xlib.c
new file mode 100644
index 0000000..d8392c1
--- /dev/null
+++ b/xlib.c
@@ -0,0 +1,31 @@
+
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include "xlib.h"
+
+void *xmalloc(size_t size)
+{
+ void *p = malloc(size);
+ if (p == NULL)
+ err(EXIT_FAILURE, "malloc");
+ return p;
+}
+
+void *xrealloc(void *ptr, size_t size)
+{
+ void *p = realloc(ptr, size);
+ if (p == NULL)
+ err(EXIT_FAILURE, "realloc");
+ return p;
+}
+
+char *xstrdup(const char *str)
+{
+ char *s = strdup(str);
+ if (s == NULL)
+ err(EXIT_FAILURE, "strdup");
+ return s;
+}
+