blob: 267cf569b5a8732b8900e7fbda1ab0d032e24df2 [file] [log] [blame]
Guido van Rossumbe0e9421993-12-24 10:32:00 +00001/***********************************************************
Guido van Rossumfd71b9e2000-06-30 23:50:40 +00002Copyright (c) 2000, BeOpen.com.
3Copyright (c) 1995-2000, Corporation for National Research Initiatives.
4Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
5All rights reserved.
Guido van Rossumbe0e9421993-12-24 10:32:00 +00006
Guido van Rossumfd71b9e2000-06-30 23:50:40 +00007See the file "Misc/COPYRIGHT" for information on usage and
8redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
Guido van Rossumbe0e9421993-12-24 10:32:00 +00009******************************************************************/
10
11/* A perhaps slow but I hope correct implementation of memmove */
12
13extern char *memcpy();
14
15char *
16memmove(dst, src, n)
17 char *dst;
18 char *src;
19 int n;
20{
21 char *realdst = dst;
22 if (n <= 0)
23 return dst;
24 if (src >= dst+n || dst >= src+n)
25 return memcpy(dst, src, n);
26 if (src > dst) {
27 while (--n >= 0)
28 *dst++ = *src++;
29 }
30 else if (src < dst) {
31 src += n;
32 dst += n;
33 while (--n >= 0)
34 *--dst = *--src;
35 }
36 return realdst;
37}