3 ms·
That’s exactly why you shouldn’t be using it: it does a very bad job at that, with behavior basically nobody wants.
by saagarjha 2y ago
That’s exactly why you shouldn’t be using it: it does a very bad job at that, with behavior basically nobody wants.
- Someone 2y agoBut doing that if you have a large ancient C code base is a lot of work. The reason for the existence of strlcpy isn’t that it is perfect, it’s that it’s the best option with good UX for integration into an existing C code base.
- saagarjha 2y agoIt's not, though. That's the point: the interface it provides is not very good. The API surface for "I have a string here and I want you to put it there but only the first n bytes" is well-defined and can be done in a much better way than what strlcpy does.