Update memmove(3) to current coding conventions.

This commit is contained in:
Jonas 'Sortie' Termansen 2014-09-24 21:14:21 +02:00
parent 51f25b0b65
commit ba0d5b3a09
1 changed files with 8 additions and 3 deletions

View File

@ -22,17 +22,22 @@
*******************************************************************************/
#include <stdint.h>
#include <string.h>
extern "C" void* memmove(void* dest_ptr, const void* src_ptr, size_t n)
{
unsigned char* dest = (unsigned char*) dest_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++ )
dest[i] = src[i];
}
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;
}