mirror of
https://github.com/vivier/EMILE.git
synced 2026-04-19 18:16:35 +00:00
libunix: add memmove()
This commit is contained in:
+1
-1
@@ -12,7 +12,7 @@ LIBRARY = libunix.a
|
||||
SOURCES = divsi3.S modsi3.S mulsi3.S udivsi3.S umodsi3.S free.c malloc.c \
|
||||
memcpy.c memset.c printf.c putchar.c puts.c read.c sprintf.c \
|
||||
strcpy.c strlen.c strncpy.c vsprintf.c write.c strcmp.c \
|
||||
strncmp.c strtol.c strdup.c
|
||||
strncmp.c strtol.c strdup.c memmove.c
|
||||
|
||||
HEADERS =
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
*
|
||||
* (c) 2025 Laurent Vivier <Laurent@Vivier.EU>
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
void *memmove(void *dest, const void *src, size_t n)
|
||||
{
|
||||
unsigned char *d = dest;
|
||||
const unsigned char *s = src;
|
||||
|
||||
if (d == s || n == 0)
|
||||
return dest;
|
||||
|
||||
if (d < s)
|
||||
{
|
||||
while (n--)
|
||||
*d++ = *s++;
|
||||
}
|
||||
else
|
||||
{
|
||||
d += n;
|
||||
s += n;
|
||||
while (n--)
|
||||
*--d = *--s;
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
Reference in New Issue
Block a user