mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-17 20:52:37 +01:00
Added memCmp.
This commit is contained in:
@@ -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"
|
||||
|
||||
17
src/crt.cpp
17
src/crt.cpp
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user