Bump version to 0.9.1.
[python/dscho.git] / Python / memmove.c
blobf44bf0433a5e6a5d0df1117b302f95ab40289a7b
1 /***********************************************************
2 Copyright (c) 2000, BeOpen.com.
3 Copyright (c) 1995-2000, Corporation for National Research Initiatives.
4 Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
5 All rights reserved.
7 See the file "Misc/COPYRIGHT" for information on usage and
8 redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
9 ******************************************************************/
11 /* A perhaps slow but I hope correct implementation of memmove */
13 extern char *memcpy(char *, char *, int);
15 char *
16 memmove(char *dst, char *src, int n)
18 char *realdst = dst;
19 if (n <= 0)
20 return dst;
21 if (src >= dst+n || dst >= src+n)
22 return memcpy(dst, src, n);
23 if (src > dst) {
24 while (--n >= 0)
25 *dst++ = *src++;
27 else if (src < dst) {
28 src += n;
29 dst += n;
30 while (--n >= 0)
31 *--dst = *--src;
33 return realdst;