Updating HEAD branch #4; Merging CABAL -> HEAD.
[tinc] / lib / xmalloc.c
index 037fab8..e1ab314 100644 (file)
@@ -21,6 +21,7 @@
 
 #include <sys/types.h>
 #include <stdio.h>
+#include <string.h>
 
 #if STDC_HEADERS
 # include <stdlib.h>
@@ -124,6 +125,18 @@ xrealloc (p, n)
   return p;
 }
 
+/* Duplicate a string */
+
+char *xstrdup(const char *s)
+{
+  char *p;
+  
+  p = strdup(s);
+  if(!p)
+    xalloc_fail ((int)strlen(s));
+  return p;
+}
+
 #ifdef NOT_USED
 
 /* Allocate memory for N elements of S bytes, with error checking.  */