4 ms·
Not sure I agree with the recommendation against strlcpy. While it is technically true that if you can't replace strcpy with memcpy you're using strcpy wrong, i
by corndoge 5y ago
Not sure I agree with the recommendation against strlcpy. While it is technically true that if you can't replace strcpy with memcpy you're using strcpy wrong, it's also true that most uses of strcpy are wrong, which I think is a better point to make. The stated purpose of strcpy is to copy a string, and if you're copying a string your best bet is strlcpy. The article is worded in such a way that you'd walk away thinking "I should always use memcpy."
- tptacek 5y agoI'm not a strlcpy fan, but I'll never understand recommending against string functions because they're "nonstandard". They're tiny and portable almost by definition. Vendor them in to your project.
- humanrebar 5y agoIf your project is small and self-contained, sure. If you have a large codebase, you have to at least rename to mylib_strlcpy. Then the other projects do that as well. Then you have 572 almost-clones of strlcpy. Consider this before copying code if you are part of a large codebase. Note that sufficiently popular OSS typically is.