[–] tlb 11y ago ↗ Please use strlcpy [1] instead.[1] http://www.unix.com/man-page/freebsd/3/strlcpy/ [–] meowface 11y ago ↗ I feel like developers avoid use of much safer functions like this out of some misguided belief there'll be a performance impact, unfortunately. Premature optimization etc. [–] ahomescu1 11y ago ↗ I imagine the biggest reason is actually portability. glibc [1] doesn't have strlcpy/strlcat, for example.1 - http://lwn.net/Articles/507319/
[–] meowface 11y ago ↗ I feel like developers avoid use of much safer functions like this out of some misguided belief there'll be a performance impact, unfortunately. Premature optimization etc. [–] ahomescu1 11y ago ↗ I imagine the biggest reason is actually portability. glibc [1] doesn't have strlcpy/strlcat, for example.1 - http://lwn.net/Articles/507319/
[–] ahomescu1 11y ago ↗ I imagine the biggest reason is actually portability. glibc [1] doesn't have strlcpy/strlcat, for example.1 - http://lwn.net/Articles/507319/
[–] nly 11y ago ↗ Putting aside the fact that using sizeof is risky in itself, i'd argue the default form should be strncpy (buffer, "abcd", sizeof(buffer)); assert (!buffer[sizeof(buffer) - 1]);
4 comments
[ 3.5 ms ] story [ 19.5 ms ] thread[1] http://www.unix.com/man-page/freebsd/3/strlcpy/
1 - http://lwn.net/Articles/507319/