I might be going insane, but I don't think I've ever seen this in c++ (though my reference code is in C). Why is there a static on the return value of the code here and what impact does it have? I don't think I've ever seen a static function outside class scope (but obviously C doesn't have classes and this probably has a different syntactical meaning).
/* just like strlen(3), but cap the number of bytes we count */
static size_t strnlen(const char *s, size_t max) {
register const char *p;
for(p = s; *p && max--; ++p);
return(p - s);
}