summaryrefslogtreecommitdiff
path: root/libc/string/string.c
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-03-08 07:33:05 +0000
committerEric Andersen <andersen@codepoet.org>2001-03-08 07:33:05 +0000
commitbfb8f8f6ea438e632e808868c44af2bff196cc18 (patch)
tree64f462a3d19751199ef10a3eda192b8b023f5c0d /libc/string/string.c
parent1e26922dfcadb624e4b2dd26c7d2b99477814e91 (diff)
Add strnlen
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