From abf6adeba064b8343d8e95c9bffe87550ba1aa76 Mon Sep 17 00:00:00 2001 From: Eugene Triguba Date: Sat, 12 Jul 2025 16:01:06 -0400 Subject: Remove need for strlcat and remove extra `memset`s --- src/strlcat.c | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 src/strlcat.c (limited to 'src/strlcat.c') diff --git a/src/strlcat.c b/src/strlcat.c deleted file mode 100644 index ccd3720..0000000 --- a/src/strlcat.c +++ /dev/null @@ -1,31 +0,0 @@ -// NOTE: `strlcat` is a safer version of `strcat` that ensures the destination -// buffer is not overflowed. However, it's not available in all standard -// libraries. Therefore, we conditionally include it here depending on if the -// system has it available by default. -#include -#include - -size_t strlcat(char *dst, const char *src, size_t dstsize) { - char *d = dst; - const char *s = src; - size_t n = dstsize; - size_t dlen; - - /* Find the end of dst and adjust bytes left but don't go past end */ - while (n-- != 0 && *d != '\0') - d++; - dlen = d - dst; - n = dstsize - dlen; - - if (n == 0) return (dlen + strlen(s)); - while (*s != '\0') { - if (n != 1) { - *d++ = *s; - n--; - } - s++; - } - *d = '\0'; - - return (dlen + (s - src)); -} -- cgit v1.2.3