diff options
Diffstat (limited to 'src/libc/string')
-rw-r--r-- | src/libc/string/string.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libc/string/string.c b/src/libc/string/string.c index ac1c757..014be4a 100644 --- a/src/libc/string/string.c +++ b/src/libc/string/string.c @@ -115,6 +115,15 @@ char *strdup(const char *s) { return buf; } +size_t strnlen(const char *s, size_t len) { + for (size_t i = 0; i < len; i++) { + if (!s[i]) { + return i; + } + } + return len; +} + /* strings.h */ int strcasecmp(const char *s1, const char *s2) { return strncasecmp(s1, s2, ~0); |