ti83-sdk/lib83/memmove.c

25 lines
485 B
C
Raw Permalink Normal View History

2023-10-08 12:52:17 +00:00
#include <string.h>
void * memmove(void * dst, void * src, size_t acount) {
2023-10-08 13:05:03 +00:00
register void * ret = dst;
register char * d;
register char * s;
2023-10-08 12:52:17 +00:00
2023-10-08 13:05:03 +00:00
if (src < dst && (char *)src + acount > dst) {
2023-10-08 12:52:17 +00:00
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);
}