Re: [reSIProcate] Visual Studio 2005 compilation warnings of 1.4 branch
On 12/10/08 2:41 PM, Matthias Moetje wrote:
But it will be markedly slower when copying strings into buffers that
are on the order of the correct size, which is by far the more common
case -- you end up scanning the string twice to comply with the behavior
specified for strcpy_s.
Very true, but I really doubt that it's possible to achieve the
Behavior of the *_s functions (ie. not to copy anything to the
dest buffer if it's not large enough) without iterating through
the string two times....
And that's their main flaw.
If you want an alternate model to emulate, you're far better off with
strlcpy -- you can perform the same checks as strcpy_s without the
performance penalty (and it doesn't null-fill the buffer like strncpy).
I read about these strl* functions but I thought that those are
OpenBSD specific. If there are free implementations for all relevant
functions (not just for strlcpy) then I'd really be fine with
using this approach! (not just because it would avoid MSVC compiler
warnings ;-)
All of the BSD libc functions are available under a BSD license, which
is fully compatible with the resiprocate license. These functions in
particular are very short, and importing them into our copy of ares
would be reasonable.
To be clear, I second Jason's sentiment that any non-contrib code should
be using the appropriate Data methods for buffer manipulation, not libc.
/a