X-Git-Url: https://git.deb.at/?a=blobdiff_plain;f=xmalloc.c;h=2b7fda6b666f2b0d715050b3ad486ff19a74c773;hb=47ca9ac04785f2d48d28886cbc4e2802b19dd9cf;hp=bc22a97b19faa6867ee9f8535a5b0ea52d3e2a3b;hpb=384a832f989722381d0ad998a87d52f2ce05b714;p=pkg%2Fabook.git diff --git a/xmalloc.c b/xmalloc.c index bc22a97..2b7fda6 100644 --- a/xmalloc.c +++ b/xmalloc.c @@ -36,6 +36,7 @@ #include #include #include +#include "xmalloc.h" static void xmalloc_default_error_handler(int err) @@ -134,10 +135,16 @@ xrealloc_inc(void *ptr, size_t size, size_t inc) return ptr; } -void -xfree(void *ptr) +char * +xstrdup(const char *s) { - free(ptr); - ptr = NULL; + size_t len = strlen(s); + void *new; + + new = xmalloc_inc(len, 1); + if(new == NULL) + return NULL; + + return (char *)memcpy(new, s, len + 1); }