2 ms·
strscpy, unlike literally everything in the standard but memccpy, is a good replacement. Not only does it avoid the usual performance pitfalls, it lets you safe
by saagarjha 4y ago
strscpy, unlike literally everything in the standard but memccpy, is a good replacement. Not only does it avoid the usual performance pitfalls, it lets you safely create your own desired functionality on top of it: in other words, it’s is composable. This is not true of any of the other functions. You can make your own strlcpy or strncpy (not sure why you would, but bear with me) out of strscpy. Trying to go in the reverse direction without paying a large cost is not possible.
(For a more detailed discussion, I wrote a whole blog post about why strncpy is good and it got posted here a while back: https://news.ycombinator.com/item?id=27537900 https://news.ycombinator.com/item?id=27537900)
- saagarjha 4y ago*why strscpy is good, my iPhone has unfortunately learned the spelling of commonly-used C functions