Add strndup

joerg at joerg at
Wed Jun 21 06:23:51 PDT 2006

On Wed, Jun 21, 2006 at 01:13:20AM -0700, Matthew Dillon wrote:
>     I need to amend this comment, because I implied that strlen() had to
>     be taken.  In fact, it's a bit more complex then that.  strndup() is
>     not allowed to scan the string beyond the specified maximum length
>     (because the string might not be terminated, as would be the case if
>     strndup() were used to cut out strings from a memory-mapped file).

And the unrolled loop can be even slower than strlen(). memchr would be
better for this purpose, but the issue remains: the interface has
potential for unexpected abuse / side effects.


More information about the Submit mailing list