Any comments, suggestions, swears concerning adding a new function,
strndup(), to libc?
So that instead of permitting it to attempt to allocate a large chunk of
memory, it is possible to give it a max length.
char *
strndup(str, max_len)
const char *str;
size_t max_len;
{
size_t len;
char *copy;
len = strlen(str) + 1;
if (len > max_len)
len = max_len;
if ((copy = malloc(len)) == NULL)
return (NULL);
memcpy(copy, str, len);
return (copy);
}
--
Daniel Hemmerich
[EMAIL PROTECTED]
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message
- Re: adding a new function to libc Daniel Hemmerich
- Re: adding a new function to libc Peter Seebach
- Re: adding a new function to libc Terry Lambert
- Re: adding a new function to libc Valentin Nechayev
- Re: adding a new function to libc Peter Pentchev
- Re: adding a new function to libc Valentin Nechayev
- Re: adding a new function to libc Assar Westerlund
- Re: adding a new function to libc Bakul Shah
- Re: adding a new function to libc Kris Kennaway
- Re: adding a new function to libc Terry Lambert

