vsnprintf: Added null string unit test.

This commit is contained in:
Branimir Karadžić
2017-02-08 22:44:37 -08:00
parent db48bee874
commit f35926dbfa
3 changed files with 18 additions and 4 deletions

View File

@@ -107,8 +107,13 @@ namespace bx
size_t strnlen(const char* _str, size_t _max)
{
const char* ptr;
for (ptr = _str; 0 < _max && *ptr != '\0'; ++ptr, --_max) {};
if (NULL == _str)
{
return 0;
}
const char* ptr = _str;
for (; 0 < _max && *ptr != '\0'; ++ptr, --_max) {};
return ptr - _str;
}