Chore: use ffStrCopyN instead of strlcpy

This commit is contained in:
李通洲
2024-10-17 22:29:38 +08:00
parent 9bd692dffb
commit 48bb5b8746
7 changed files with 29 additions and 17 deletions
+11
View File
@@ -79,3 +79,14 @@ static inline bool ffCharIsDigit(char c)
{
return '0' <= c && c <= '9';
}
static inline char* ffStrCopyN(char* __restrict__ dst, const char* __restrict__ src, size_t nDst)
{
assert(dst != NULL);
if (__builtin_expect(dst == NULL, false)) return dst;
size_t len = strnlen(src, nDst - 1);
memcpy(dst, src, len);
dst[len] = '\0';
return dst + len;
}