David Laight wrote:
Yes, but they are much more likely to fit into the function scope optimization if they are inlined.Inlining them would (probably) be bad news. They are not a completely trivial size (ie smaller than the call sequence) and they are more likely to be resident in the Icache if they are functions.
ahem. The code should be:They are useful though, and do what the programmer wanted (unlike strncpy whose only point is that it doesn't overrun the target buffer). However in this case they aren't quite right! len = strlcpy(buf, s0, buflen); len += strlcpy(buf + len, s1, buflen - len) len += strlcpy(buf + len, s2, buflen - len)
strlcpy(buf, s0, buflen);
strlcat(buf, s1, buflen);
strlcat(buf, s2, buflen);
If you are going to be sliding the buffer with each call, then you can just as well use your functions.
is slightly more complex than using my str_add().
The source for the functions can be grabbed from netbsd or freebsd.
David