mirror of
git://sourceware.org/git/glibc.git
synced 2024-11-21 01:12:26 +08:00
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:
parent
61965e9b17
commit
6f25696828
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user