This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Implement C11 annex K?


David A. Wheeler wrote:
if you are *handed* a block of memory to use (with its length),
or if dynamic allocation is forbidden

That example reponded to Russ Allbery, who asked for dynamic allocation. Other techniques should be used for fixed-size buffers. For reasons that should be obvious I don't recommend the technique of silent truncation; but applications that require it can use snprintf, which is more portable and useful than strlcpy anyway.

Don't tell me "write it perfectly", that's been failing for 4 decades+ now.

That's a false choice. It's not strlcpy versus "write it perfectly". It's strlcpy versus other available approaches. And the little empirical evidence that we have suggests that strlcpy is worse.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]