* bug #23163: various minor fixes for the benefit of older Unixes
[mmh] / sbr / memmove.c
diff --git a/sbr/memmove.c b/sbr/memmove.c
new file mode 100644 (file)
index 0000000..62a303f
--- /dev/null
@@ -0,0 +1,11 @@
+/* public domain function from Jan Wolter Unix Incompatibility Notes */
+/* http://unixpapa.com/incnote/ */
+char *memmove(char *dst, char *src, int n)
+{
+  if (src > dst)
+    for ( ; n > 0; n--)
+      *(dst++)= *(src++);
+  else
+    for (dst+= n-1, src+= n-1; n > 0; n--)
+      *(dst--)= *(src--);
+}