4 ms·
> The primary complaint about strlcpy() is that it gives no indication of whether the copied string was truncated or not. So how hard would it be to add a retu
by smegel 12y ago
> The primary complaint about strlcpy() is that it gives no indication of whether the copied string was truncated or not.
So how hard would it be to add a return value indicating this?
- ploxiln 12y agoIf you did, it wouldn't be strlcpy() anymore. The point is compatibility with existing users and expectations.
- lutusp 12y agoCan't do that -- strlcpy already has a defined return value. To change it would break vast amounts of existing code.
- zik 12y agoThe author of the article got this wrong. The return value is the number of characters it tried to write so it's easy enough to compare with the buffer size to see if truncation occurred.