Sat Jul 27 04:37:34 1996 Ulrich Drepper <drepper@cygnus.com>

* string/string.h (strndupa): Change to use return value of
	`memcpy' for more performance.
	* string/strndup.c: Likewise.
This commit is contained in:
Roland McGrath 1996-07-27 09:36:38 +00:00
parent 61965e9b17
commit 6f25696828

View File

@ -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)