summaryrefslogtreecommitdiff
path: root/src/lib/memmove.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/memmove.c')
-rw-r--r--src/lib/memmove.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/lib/memmove.c b/src/lib/memmove.c
new file mode 100644
index 0000000000..0a4908325e
--- /dev/null
+++ b/src/lib/memmove.c
@@ -0,0 +1,20 @@
+#include <string.h>
+void *memmove(void *vdest, const void *vsrc, size_t count)
+{
+ const char *src = vsrc;
+ char *dest = vdest;
+ int i;
+
+ if (dest <= src) {
+ while (count--) {
+ *dest++ = *src++;
+ }
+ } else {
+ src += count - 1;
+ dest += count - 1;
+ while(count--) {
+ *dest-- = *src--;
+ }
+ }
+ return vdest;
+}