summaryrefslogtreecommitdiff
path: root/exp_memmove.c
diff options
context:
space:
mode:
Diffstat (limited to 'exp_memmove.c')
-rw-r--r--exp_memmove.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/exp_memmove.c b/exp_memmove.c
new file mode 100644
index 0000000..324bc2d
--- /dev/null
+++ b/exp_memmove.c
@@ -0,0 +1,25 @@
+/* memmove - some systems lack this */
+
+#include "expect_cf.h"
+#include "tcl.h"
+
+/* like memcpy but can handle overlap */
+#ifndef HAVE_MEMMOVE
+char *
+memmove(dest,src,n)
+VOID *dest;
+CONST VOID *src;
+int n;
+{
+ char *d;
+ CONST char *s;
+
+ d = dest;
+ s = src;
+ if (s<d && (d < s+n)) {
+ for (d+=n, s+=n; 0<n; --n)
+ *--d = *--s;
+ } else for (;0<n;--n) *d++ = *s++;
+ return dest;
+}
+#endif /* HAVE_MEMMOVE */