Fixed strnlen.

This commit is contained in:
Branimir Karadžić
2016-09-08 09:19:01 -07:00
parent 52ccba7737
commit a52858520f
2 changed files with 10 additions and 2 deletions

View File

@@ -43,9 +43,8 @@ namespace bx
///
inline size_t strnlen(const char* _str, size_t _max)
{
const char* end = _str + _max;
const char* ptr;
for (ptr = _str; ptr < end && *ptr != '\0'; ++ptr) {};
for (ptr = _str; 0 < _max && *ptr != '\0'; ++ptr, --_max) {};
return ptr - _str;
}