# HG changeset patch # User Sebastien Decugis # Date 1350833163 -7200 # Node ID 536e8d11edee2a08ca2487a5e0d3dfbe7384b790 # Parent 12e7fcbc1b216c4af0143500af05514cbd5a80ac Avoid using strnlen since it is also missing from Mac OS X diff -r 12e7fcbc1b21 -r 536e8d11edee libfdproto/portability.c --- a/libfdproto/portability.c Sun Oct 21 17:15:22 2012 +0200 +++ b/libfdproto/portability.c Sun Oct 21 17:26:03 2012 +0200 @@ -51,7 +51,15 @@ char * strndup (char *str, size_t len) { char * output; - size_t outlen = strnlen (str, len); + size_t outlen; + + output = memchr(str, 0, len); + if (output == NULL) { + outlen = len; + } else { + outlen = term - str; + } + CHECK_MALLOC_DO( output = malloc (outlen + 1), return NULL ); output[outlen] = '\0';