aboutsummaryrefslogtreecommitdiffstats
path: root/xlib.c
diff options
context:
space:
mode:
authorNatanael Copa <natanael.copa@gmail.com>2008-12-18 21:22:55 +0100
committerNatanael Copa <natanael.copa@gmail.com>2008-12-18 21:22:55 +0100
commit8377d611fc80fc0d9e498d958c40fce59f3f29e1 (patch)
tree201010526cf2d6d8036cb9f6334043a9e8d51171 /xlib.c
parent518df3c6280fa4829d6e389da6ade6a025c2e6c0 (diff)
downloadpingu-8377d611fc80fc0d9e498d958c40fce59f3f29e1.tar.bz2
pingu-8377d611fc80fc0d9e498d958c40fce59f3f29e1.tar.xz
xlib.c: moved utility funcs to separate file
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;
+}
+