mirror of
https://github.com/ipxe/ipxe
synced 2025-12-17 18:11:49 +03:00
move strndup back to string.c - used by strdup
This commit is contained in:
@@ -333,6 +333,21 @@ void * memchr(const void *s, int c, size_t n)
|
|||||||
|
|
||||||
#endif
|
#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) {
|
char * strdup(const char *s) {
|
||||||
return strndup(s, ~((size_t)0));
|
return strndup(s, ~((size_t)0));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user