On 2023-11-10 03:05, Alejandro Colomar wrote:
Hopefully, it won't be so bad in terms of performance.
It's significantly slower than strncpy for typical use (smallish fixed-size destination buffers). So just use strncpy for that. It may be bad, but it's better than the alternatives you've mentioned. You can package strncpy inside a [[nodiscard]] inline wrapper if you like.
More importantly, the manual should not push strlcpy as being superior or being in any way a "fix" for strncpy's problems. strlcpy is worse than strncpy in important ways and besides - as mentioned in the glibc manual - neither function is a good choice for string processing.