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