/* The strnlen() function returns the number of characters in the string pointed to by s, excluding the terminating null byte ('\0'), but at most maxlen. In doing this, strnlen() looks only at the first maxlen characters in the string pointed to by s and never beyond s+maxlen. */
rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen)
/* The strnlen() function returns the number of characters in the string pointed to by s, excluding the terminating null byte ('\0'), but at most maxlen. In doing this, strnlen() looks only at the first maxlen characters in the string pointed to by s and never beyond s+maxlen. */
rt_size_t rt_strnlen(const char *s, rt_ubase_t maxlen)
{
    const char *sc;
    for (sc = s; *sc != '\0' && (rt_ubase_t)(sc - s) < maxlen; ++sc)
        ;
    return sc - s;
}