From 6f2569682835f0ece6da858491f07a8aa53ee0d6 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 27 Jul 1996 09:36:38 +0000 Subject: Sat Jul 27 04:37:34 1996 Ulrich Drepper * string/string.h (strndupa): Change to use return value of `memcpy' for more performance. * string/strndup.c: Likewise. --- string/strndup.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/string/strndup.c b/string/strndup.c index 8757b869d5..72635bb97c 100644 --- a/string/strndup.c +++ b/string/strndup.c @@ -22,7 +22,7 @@ Cambridge, MA 02139, USA. */ char * -strndup (const char *s, size_t n) +__strndup (const char *s, size_t n) { size_t len = strnlen (s, n); char *new = malloc (len + 1); @@ -30,9 +30,7 @@ strndup (const char *s, size_t n) if (new == NULL) return NULL; - memcpy (new, s, len); new[len] = '\0'; - - return new; + return memcpy (new, s, len); } - +weak_alias (__strndup, strndup) -- cgit v1.2.3