4 ms·
Here's a better idea: Stop using the str* functions completely. Start using buffers with explicit length fields attached, and start using the mem* functions.
by charliesome 14y ago
Here's a better idea: Stop using the str* functions completely. Start using buffers with explicit length fields attached, and start using the mem* functions.
- simias 14y agoEach has its uses. The standard C and C++ library use C-strings for many things, so if you want to use, say, fopen you'd have to have a conversion routine set up (at additional memory and cpu cost). Just yesterday the ex-protobuf guy explained that in his new format (whose name I forgot) he uses null terminated strings exactly for that, even though he also stores the length of the string already. But then, it's just C strings vs. Pascal strings all over again. It's your job as an engineer to use the right tool at the right time. On the other end, it sucks that strlcpy is not as portable as the n counterparts. Last time I checked, the gnu libc still didn't have it for stupid bikeshed reasons.
- evadne 14y agohttp://kentonv.github.com/capnproto http://kentonv.github.com/capnproto
- Nick_C 14y ago> the gnu libc still didn't have it for stupid bikeshed reasons Yep, still doesn't. Not so much for bikeshed reasons, but more for the Gnu people's stupid NIH reasons. OpenBSD offered it to them, reply was along the lines of "we don't see the need for it".