25 lines
478 B
C
25 lines
478 B
C
|
|
#include <string.h>
|
|
|
|
void * memmove(void * dst, void * src, size_t acount) {
|
|
void * ret = dst;
|
|
char * d;
|
|
char * s;
|
|
|
|
if (((int)src < (int)dst) && ((((int)src) + acount) > (int)dst)) {
|
|
d = ((char *)dst) + acount - 1;
|
|
s = ((char *)src) + acount - 1;
|
|
while (acount--) {
|
|
*d-- = *s--;
|
|
}
|
|
} else {
|
|
d = dst;
|
|
s = src;
|
|
while (acount--) {
|
|
*d++ = *s++;
|
|
}
|
|
}
|
|
|
|
return (ret);
|
|
}
|