memmove.c - scc - simple c99 compiler
(HTM) git clone git://git.simple-cc.org/scc
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) Submodules
(DIR) README
(DIR) LICENSE
---
memmove.c (259B)
---
1 #include <string.h>
2
3 #undef memmove
4
5 void *
6 memmove(void *s1, const void *s2, size_t n)
7 {
8 char *d = s1;
9 const char *s = s2;
10
11 if (d < s) {
12 while (n-- > 0)
13 *d++ = *s++;
14 } else {
15 s += n-1, d += n-1;
16
17 while (n-- > 0)
18 *d-- = *s--;
19 }
20 return s1;
21 }