1 #include <string.h> 2 strnlen(const char * s,size_t n)3 size_t strnlen(const char *s, size_t n) 4 { 5 const char *p = memchr(s, 0, n); 6 return p ? p-s : n; 7 } 8