aboutsummaryrefslogtreecommitdiffstats
path: root/src/xlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/xlib.c')
-rw-r--r--src/xlib.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/xlib.c b/src/xlib.c
new file mode 100644
index 0000000..0bc8123
--- /dev/null
+++ b/src/xlib.c
@@ -0,0 +1,37 @@
+
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+
+#include <err.h>
+#include <netdb.h>
+#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;
+}
+