At 06:03 PM 1/5/2002 +0000, Jim Winstead wrote:
>Andi Gutmans <[EMAIL PROTECTED]> wrote:
> > If you need to use something like strncat()/strncpy() you should use
> > strlcpy()/strlcat(). We changed to these functions a couple of years ago.
>
>in the case of wordwrap(), it is only copying part of the source string,
>so strlcat() wouldn't do the job. i figured it'd be more confusing to
>mix calls to strncat() and strlcat() in the same function than to just
>use strncat() consistently. the destination buffer is verifiably large
>enough to handle all of the strncat() calls.

You're missing the point. In order to minimize the amount of API misuse of 
the str*cat() family of functions we decided only to use the ones I 
mentioned, everywhere. I am sure that you're code is correct but all places 
should use strlcat()/strlcpy() if they are using the str* family of functions.

>(now, i did think of keeping track of the current position in the
>destination buffer and using memcpy(), but it seemed like overkill. the
>size of the new buffer could be calculated more intelligently, too, by
>taking into account the requested line length and size of the original
>text to figure out the maximum number of breaks that will be inserted.
>but that's all optimization. i was mainly out to fix the segfault.)

memcpy() is always better but it sometimes isn't worth the gain like 
possibly in your case
I didn't mean for you to rewrite it with memcpy() because I know it can be 
a bitch and isn't always worth it but I'd like to keep PHP consistent with 
the mentioned functions.

Andi


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to