svn commit: r203391 - head/lib/libc/string
Ed Schouten
ed at FreeBSD.org
Tue Feb 2 19:02:09 UTC 2010
Author: ed
Date: Tue Feb 2 19:02:08 2010
New Revision: 203391
URL: http://svn.freebsd.org/changeset/base/203391
Log:
Implement strndup(3) using strnlen(3).
This makes the implementation a bit more consistent with strdup(3),
which uses strlen(3).
Modified:
head/lib/libc/string/strndup.c
Modified: head/lib/libc/string/strndup.c
==============================================================================
--- head/lib/libc/string/strndup.c Tue Feb 2 18:50:02 2010 (r203390)
+++ head/lib/libc/string/strndup.c Tue Feb 2 19:02:08 2010 (r203391)
@@ -42,9 +42,7 @@ strndup(const char *str, size_t n)
size_t len;
char *copy;
- for (len = 0; len < n && str[len]; len++)
- continue;
-
+ len = strnlen(str, n);
if ((copy = malloc(len + 1)) == NULL)
return (NULL);
memcpy(copy, str, len);
More information about the svn-src-all
mailing list