2
0
mirror of https://github.com/xcat2/xNBA.git synced 2024-12-13 23:01:31 +00:00

move strndup back to string.c - used by strdup

This commit is contained in:
Holger Lubitz 2007-08-02 01:48:20 +02:00
parent 6b6dbe5600
commit bb94c143d9

View File

@ -333,6 +333,21 @@ void * memchr(const void *s, int c, size_t n)
#endif
char * strndup(const char *s, size_t n)
{
size_t len = strlen(s);
char *new;
if (len>n)
len = n;
new = malloc(len+1);
if (new) {
new[len] = '\0';
memcpy(new,s,len);
}
return new;
}
char * strdup(const char *s) {
return strndup(s, ~((size_t)0));
}