From 82f29da5bb9ec58b2210af86aa8a54c3d48d0f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Thu, 9 Feb 2017 19:30:52 -0800 Subject: [PATCH] Cleanup. --- include/bx/bx.h | 2 +- src/crt.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/bx/bx.h b/include/bx/bx.h index f623b58..25469d8 100644 --- a/include/bx/bx.h +++ b/include/bx/bx.h @@ -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 diff --git a/src/crt.cpp b/src/crt.cpp index 9fbc208..57f448a 100644 --- a/src/crt.cpp +++ b/src/crt.cpp @@ -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); }