This commit is contained in:
Branimir Karadžić
2017-02-09 19:30:52 -08:00
parent 878883f568
commit 82f29da5bb
2 changed files with 9 additions and 7 deletions

View File

@@ -63,7 +63,7 @@ namespace bx
void memSet(void* _dst, uint8_t _ch, size_t _numBytes);
///
int32_t memCmp(const char* _lhs, const char* _rhs, size_t _numBytes);
int32_t memCmp(const void* _lhs, const void* _rhs, size_t _numBytes);
} // namespace bx

View File

@@ -121,19 +121,21 @@ namespace bx
#endif // BX_CRT_NONE
}
int32_t memCmpRef(const char* _lhs, const char* _rhs, size_t _numBytes)
int32_t memCmpRef(const void* _lhs, const void* _rhs, size_t _numBytes)
{
const char* lhs = (const char*)_lhs;
const char* rhs = (const char*)_rhs;
for (
; 0 < _numBytes && *_lhs == *_rhs
; ++_lhs, ++_rhs, --_numBytes
; 0 < _numBytes && *lhs == *rhs
; ++lhs, ++rhs, --_numBytes
)
{
}
return 0 == _numBytes ? 0 : *_lhs - *_rhs;
return 0 == _numBytes ? 0 : *lhs - *rhs;
}
int32_t memCmp(const char* _lhs, const char* _rhs, size_t _numBytes)
int32_t memCmp(const void* _lhs, const void* _rhs, size_t _numBytes)
{
#if BX_CRT_NONE
return memCmpRef(_lhs, _rhs, _numBytes);
@@ -443,7 +445,7 @@ extern "C" void* memset(void* _dst, int _ch, size_t _numBytes)
return _dst;
}
extern "C" int32_t memcmp(const char* _lhs, const char* _rhs, size_t _numBytes)
extern "C" int32_t memcmp(const void* _lhs, const void* _rhs, size_t _numBytes)
{
return bx::memCmp(_lhs, _rhs, _numBytes);
}