chsvlib
chsv helper source code

◆ strnLen_s()

std:: size_t Chusov::String::strnLen_s ( const char *  pszStr,
std::size_t  cchStr 
)
noexcept

Returns a size, in bytes, of a string excluding the terminating zero, if any. The function implements the strnlen_s function of the ISO/IEC TR 24731-1 standard.

Parameters
[in]pszStris a pointer to a string of the returned length. The parameter may be NULL, the function returns 0 in this case.
[in]cchStris a size, in bytes, of the buffer where the string is located. It is treated as a maximum length of the string. Thus the returned value is less or equal to cchStr. The parameter is ignored if pszStr is NULL.
Returns
If the pszStr pointer is NULL, the function returns 0. Otherwise the function returns a length, in bytes, of the string pointed to by pszStr. If the cchStr characters constitute a zero-terminated string the function behaves identically to strLen, returning a number of bytes before the null terminator. Otherwise the function returns cchStr.
See also
strLen;
wcsnLen_s.