Added memCmp.

This commit is contained in:
Branimir Karadžić
2017-02-08 21:51:02 -08:00
parent 14576bdbe4
commit 4bc558a998
2 changed files with 20 additions and 0 deletions

View File

@@ -62,6 +62,9 @@ namespace bx
///
void memSet(void* _dst, uint8_t _ch, size_t _numBytes);
///
int32_t memCmp(const char* _lhs, const char* _rhs, size_t _numBytes);
} // namespace bx
#include "bx.inl"

View File

@@ -121,6 +121,18 @@ namespace bx
#endif // BX_CRT_NONE
}
int32_t memCmp(const char* _lhs, const char* _rhs, size_t _numBytes)
{
for (
; 0 < _numBytes && *_lhs == *_rhs
; ++_lhs, ++_rhs, --_numBytes
)
{
}
return 0 == _numBytes ? 0 : *_lhs - *_rhs;
}
namespace
{
struct Param
@@ -417,4 +429,9 @@ extern "C" void* memset(void* _dst, int _ch, size_t _numBytes)
bx::memSet(_dst, uint8_t(_ch), _numBytes);
return _dst;
}
extern "C" int32_t memcmp(const char* _lhs, const char* _rhs, size_t _numBytes)
{
return bx::memCmp(_lhs, _rhs, _numBytes);
}
#endif // BX_CRT_NONE