summaryrefslogtreecommitdiff
path: root/libc/string/string.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc/string/string.c')
-rw-r--r--libc/string/string.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/libc/string/string.c b/libc/string/string.c
index f77cf4c69..29ac83a24 100644
--- a/libc/string/string.c
+++ b/libc/string/string.c
@@ -23,6 +23,16 @@ size_t strlen(const char *str)
}
#endif
+/********************** Function strnlen ************************************/
+
+#ifdef L_strnlen
+size_t strnlen (const char *string, size_t maxlen)
+{
+ const char *end = memchr (string, '\0', maxlen);
+ return end ? end - string : maxlen;
+}
+#endif
+
/********************** Function strcat ************************************/
#ifdef L_strcat