X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=lib%2Fxmalloc.c;h=e1ab3140b79e08c5b2c0077deb564afe041b2c2d;hp=037fab87e2d6d9e4e1ab68e1cb89e9f9874c4889;hb=39e93f473d34d6cdf6f4a7f0390a3b50cbd7b564;hpb=699e159a7a1711034f1d16d68ad1974a82e12dfc diff --git a/lib/xmalloc.c b/lib/xmalloc.c index 037fab87..e1ab3140 100644 --- a/lib/xmalloc.c +++ b/lib/xmalloc.c @@ -21,6 +21,7 @@ #include #include +#include #if STDC_HEADERS # include @@ -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. */