summaryrefslogtreecommitdiff
path: root/xwrap.c
diff options
context:
space:
mode:
authormikeos <mike.osipov@gmail.com>2012-10-13 23:20:14 +0400
committermikeos <mike.osipov@gmail.com>2012-10-13 23:20:14 +0400
commit893c216b889f260378fb21a7f576c061f7ff2248 (patch)
treead4566df268c76de8fc743d006b14baf6bfb6594 /xwrap.c
initial
Diffstat (limited to 'xwrap.c')
-rw-r--r--xwrap.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/xwrap.c b/xwrap.c
new file mode 100644
index 0000000..fe158f5
--- /dev/null
+++ b/xwrap.c
@@ -0,0 +1,23 @@
+#include <string.h>
+#include <stdlib.h>
+
+#include "debug.h"
+
+void *xmalloc(size_t size)
+{
+ void *p;
+
+ p = malloc(size);
+ if (p == NULL)
+ sys_err("malloc %zd bytes", size);
+ return p;
+}
+
+char *xstrdup(const char *s)
+{
+ int len;
+
+ len = strlen(s) + 1;
+ return memcpy(xmalloc(len), s, len);
+}
+