summaryrefslogtreecommitdiff
path: root/src/libc
diff options
context:
space:
mode:
Diffstat (limited to 'src/libc')
-rw-r--r--src/libc/include/string.h2
-rw-r--r--src/libc/string/string.c9
2 files changed, 11 insertions, 0 deletions
diff --git a/src/libc/include/string.h b/src/libc/include/string.h
index d9d2b74..8b04b39 100644
--- a/src/libc/include/string.h
+++ b/src/libc/include/string.h
@@ -24,4 +24,6 @@ char *strncat(char *restrict dst, const char *restrict src, size_t n);
char *stpncpy(char *restrict dst, const char *restrict src, size_t n);
char *strdup(const char *s);
+size_t strnlen(const char *s, size_t len);
+
char *strerror(int errnum);
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);