/* Check the string length check no more than given number of characters. 
Function iterates through the string searching for the zero character. Even when it is not found it stops iterating after maximum of  */
static size_t safe_strlen(char const *str, size_t nmax)
/* Check the string length check no more than given number of characters. 
Function iterates through the string searching for the zero character. Even when it is not found it stops iterating after maximum of  */
static size_t safe_strlen(char const *str, size_t nmax)
{
    size_t n=0;
    while ('\0' != *str++)
    {
        ++n;
        if (0 == --nmax)
            break;
    }
    return n;
}