Daniel Hemmerich <[EMAIL PROTECTED]> writes:
> Any comments, suggestions, swears concerning adding a new function,
> strndup(), to libc?
See src/crypto/heimdal/lib/roken/strndup.c :-)
> 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);
> }
Doesn't work for a non-terminated str and doesn't 0-terminate the
return string when str is too long.
/assar
To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message