]> granicus.if.org Git - zziplib/commitdiff
Fix _zzip_strndup strndup is not available
authorkeneanung <keneanung@googlemail.com>
Thu, 26 Apr 2018 08:42:14 +0000 (10:42 +0200)
committerKeneanung <keneanung@googlemail.com>
Thu, 26 Apr 2018 08:45:55 +0000 (10:45 +0200)
zzip/__string.h

index cd567142fc526e2e572357853848f63a7ef23f13..2103a3bdc0fb0961a30197a579287b049422cb7a 100644 (file)
@@ -31,6 +31,7 @@ _zzip_strnlen(const char *p, size_t maxlen)
 #if defined ZZIP_HAVE_STRNDUP || defined strndup
 #define _zzip_strndup strndup
 #else
+#include <stdlib.h>
 
 /* if your system does not have strndup: */
 zzip__new__ static char *
@@ -42,7 +43,7 @@ _zzip_strndup(char const *p, size_t maxlen)
     } else 
     {
         size_t len = _zzip_strnlen(p, maxlen);
-        char* r = malloc(len + 1);
+        char* r = (char *)malloc(len + 1);
         if (r == NULL)
             return NULL; /* errno = ENOMEM */
         r[len] = '\0';