diff options
Diffstat (limited to 'libc/string/strlen.c')
-rw-r--r-- | libc/string/strlen.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libc/string/strlen.c b/libc/string/strlen.c index 95b99d2..5b408e7 100644 --- a/libc/string/strlen.c +++ b/libc/string/strlen.c @@ -25,3 +25,16 @@ strlen(const char *s) return len; } +size_t +strnlen(const char *s, size_t n) +{ + size_t len = 0; + + while (*s != 0 && n) { + len += 1; + s += 1; + n--; + } + + return len; +} |