-remove async ecc key generation, not needed
[oweals/gnunet.git] / src / util / common_allocation.c
index 22dfb2509c3538fc459c9fac07538f4b15b930e0..dfa65d579dc6b74b0e566e44baff2fc5451dcaa1 100644 (file)
@@ -256,6 +256,21 @@ GNUNET_xstrdup_ (const char *str, const char *filename, int linenumber)
 }
 
 
+#if ! HAVE_STRNLEN
+static size_t
+strnlen (const char *s, 
+        size_t n)
+{
+  const char *e;
+
+  e = memchr (s, '\0', n);
+  if (NULL == e)
+    return n;
+  return e - s;
+}
+#endif
+
+
 /**
  * Dup partially a string (same semantics as strndup).
  *
@@ -271,6 +286,8 @@ GNUNET_xstrndup_ (const char *str, size_t len, const char *filename,
 {
   char *res;
 
+  if (0 == len)
+    return GNUNET_strdup ("");
   GNUNET_assert_at (str != NULL, filename, linenumber);
   len = strnlen (str, len);
   res = GNUNET_xmalloc_ (len + 1, filename, linenumber);