2021-12-24 19:08:18 +00:00
|
|
|
#pragma once
|
|
|
|
// NOTE: These should not be inline
|
2021-11-06 15:27:13 +00:00
|
|
|
inline void* memset (void* ptr, int value, size_t num){
|
|
|
|
for( int i = 0; i < num; i++ )
|
|
|
|
{
|
2022-02-26 19:44:16 +00:00
|
|
|
unsigned char* data = (unsigned char*)ptr+ i;
|
|
|
|
*data = (unsigned char)value;
|
2021-11-06 15:27:13 +00:00
|
|
|
}
|
|
|
|
return ptr;
|
|
|
|
}
|
2021-12-24 19:08:18 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline int memcmp( const void* ptr1, const void* ptr2, size_t num)
|
|
|
|
{
|
|
|
|
const unsigned char * cs = (const unsigned char*) ptr1;
|
|
|
|
const unsigned char * ct = (const unsigned char*) ptr2;
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0 ; i < num ; i++, cs++, ct++ ){
|
|
|
|
if( *cs < *ct){
|
|
|
|
return -1;
|
|
|
|
} else if( *cs > *ct){
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|