Update memmove(3) to current coding conventions.
This commit is contained in:
parent
51f25b0b65
commit
ba0d5b3a09
|
@ -22,17 +22,22 @@
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
extern "C" void* memmove(void* dest_ptr, const void* src_ptr, size_t n)
|
extern "C" void* memmove(void* dest_ptr, const void* src_ptr, size_t n)
|
||||||
{
|
{
|
||||||
unsigned char* dest = (unsigned char*) dest_ptr;
|
unsigned char* dest = (unsigned char*) dest_ptr;
|
||||||
const unsigned char* src = (const unsigned char*) src_ptr;
|
const unsigned char* src = (const unsigned char*) src_ptr;
|
||||||
if ( dest < src )
|
if ( (uintptr_t) dest < (uintptr_t) src )
|
||||||
|
{
|
||||||
for ( size_t i = 0; i < n; i++ )
|
for ( size_t i = 0; i < n; i++ )
|
||||||
dest[i] = src[i];
|
dest[i] = src[i];
|
||||||
|
}
|
||||||
else
|
else
|
||||||
for ( size_t i = n; i != 0; i-- )
|
{
|
||||||
dest[i-1] = src[i-1];
|
for ( size_t i = 0; i < n; i++ )
|
||||||
|
dest[n-(i+1)] = src[n-(i+1)];
|
||||||
|
}
|
||||||
return dest_ptr;
|
return dest_ptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue