mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Update memmove(3) to current coding conventions.
This commit is contained in:
parent
51f25b0b65
commit
ba0d5b3a09
1 changed files with 8 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue