summaryrefslogtreecommitdiff
path: root/lib/string/strncat.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/string/strncat.c')
-rw-r--r--lib/string/strncat.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/string/strncat.c b/lib/string/strncat.c
new file mode 100644
index 0000000..a144e37
--- /dev/null
+++ b/lib/string/strncat.c
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: MIT */
+/* Derived from musl libc (Copyright © 2005-2020 Rich Felker, et al.) */
+
+#include <string.h>
+
+char *strncat(char *restrict d, const char *restrict s, size_t n)
+{
+ char *a = d;
+ d += strlen(d);
+ while (n && *s) n--, *d++ = *s++;
+ *d++ = 0;
+ return a;
+}