diff options
Diffstat (limited to 'src/commonlib/bsd/string.c')
-rw-r--r-- | src/commonlib/bsd/string.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/commonlib/bsd/string.c b/src/commonlib/bsd/string.c index 3286d41b1c..a9dce39e8d 100644 --- a/src/commonlib/bsd/string.c +++ b/src/commonlib/bsd/string.c @@ -2,6 +2,26 @@ #include <commonlib/bsd/string.h> #include <ctype.h> +#include <stddef.h> + +size_t strlen(const char *str) +{ + const char *ptr = str; + + while (*ptr++) + ; + return ptr - str - 1; +} + +size_t strnlen(const char *str, size_t maxlen) +{ + const char *ptr = str; + const char *end = str + maxlen + 1; + + while (*ptr++ && ptr < end) + ; + return ptr - str - 1; +} unsigned int skip_atoi(char **ptr) { |