ref: 7180aa94fe54c91579070dcf0518c46d17060f29
parent: 22bcaee6b85ae9fd458b5b5717847d00b7b8599f
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Sep 6 04:17:25 EDT 2018
[lib/c] Add strnlen()
--- a/lib/c/strnlen.c
+++ b/lib/c/strnlen.c
@@ -5,5 +5,9 @@
size_t
strnlen(const char *s, size_t maxlen)
{
- return 0;
+ size_t n;
+
+ for (n = 0; n < maxlen && *s++; ++n)
+ ;
+ return n;
}