changeset 851:536e8d11edee

Avoid using strnlen since it is also missing from Mac OS X
author Sebastien Decugis <sdecugis@freediameter.net>
date Sun, 21 Oct 2012 17:26:03 +0200
parents 12e7fcbc1b21
children 5873c671490f
files libfdproto/portability.c
diffstat 1 files changed, 9 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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';
"Welcome to our mercurial repository"