1#include <string.h> 2 3size_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