Re:Git's list of banned C functions
by cestith on Thursday March 04, 2021 @06:09PM
(#26349819)
This is something git does. That's why they prefer it - it's available to git everywhere.
[ Parent
| on HN ]
It's 4 lines of code to implement it. So even if it is not available on a platform (glibc mmmh because of Dreppers stubborness), it's no problem.
size_t strlcpy(char *dst, const char *src, size_t dstsize)
{
size_t len = strlen(src);
if(dstsize)
*((char*)mempcpy(dst, src, min(len, dstsize-1))) = 0;
return len;
}