libc: add strnlen implementation
This is standard function and useful for application writers.
Signed-off-by: Timo Teräs <timo.teras@iki.fi>
diff --git a/lib/libc/minimal/source/string/string.c b/lib/libc/minimal/source/string/string.c
index 51cfe2b..f965181 100644
--- a/lib/libc/minimal/source/string/string.c
+++ b/lib/libc/minimal/source/string/string.c
@@ -118,6 +118,25 @@
/**
*
+ * @brief Get fixed-size string length
+ *
+ * @return number of bytes in fixed-size string <s>
+ */
+
+size_t strnlen(const char *s, size_t maxlen)
+{
+ size_t n = 0;
+
+ while (*s != '\0' && n < maxlen) {
+ s++;
+ n++;
+ }
+
+ return n;
+}
+
+/**
+ *
* @brief Compare two strings
*
* @return negative # if <s1> < <s2>, 0 if <s1> == <s2>, else positive #