diff options
Diffstat (limited to 'na/lib/string/strlcat.c')
| -rw-r--r-- | na/lib/string/strlcat.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/na/lib/string/strlcat.c b/na/lib/string/strlcat.c new file mode 100644 index 0000000..a61821d --- /dev/null +++ b/na/lib/string/strlcat.c @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: MIT */ +/* Derived from musl libc (Copyright © 2005-2020 Rich Felker, et al.) */ + +#define _BSD_SOURCE +#include <string.h> + +size_t strlcat(char *d, const char *s, size_t n) +{ + size_t l = strnlen(d, n); + if (l == n) return l + strlen(s); + return l + strlcpy(d+l, s, n-l); +} |
