StringUtil: rename ffStrCopy and correctly reflect its usage

This commit is contained in:
李通洲
2024-11-11 18:02:23 +08:00
parent c368908b7d
commit 7c8250c68c
7 changed files with 21 additions and 21 deletions
+3 -3
View File
@@ -80,12 +80,12 @@ 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)
// Copies at most (dstBufSiz - 1) bytes from src to dst; dst is always null-terminated
static inline char* ffStrCopy(char* __restrict__ dst, const char* __restrict__ src, size_t dstBufSiz)
{
assert(dst != NULL);
if (__builtin_expect(dst == NULL, false)) return dst;
size_t len = strnlen(src, nDst - 1);
size_t len = strnlen(src, dstBufSiz - 1);
memcpy(dst, src, len);
dst[len] = '\0';
return dst + len;