DragonFly BSD
DragonFly submit List (threaded) for 2006-06
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: Add strndup


From: joerg@xxxxxxxxxxxxxxxxx
Date: Wed, 21 Jun 2006 15:21:02 +0200
Mail-followup-to: submit@crater.dragonflybsd.org

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.

Joerg



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]