Mercurial > cpython-lru_cache-weakref
annotate Python/memmove.c @ 13267:4ce255495da3 legacy-trunk
Jack Jansen, Mac patch:
If we have stat.h include it if we don't have sys/stat.h
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Sat, 01 Jul 2000 01:08:11 +0000 |
| parents | 87ee82e5c56d |
| children | f79434ee41fa |
| rev | line source |
|---|---|
| 1449 | 1 /*********************************************************** |
|
13255
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
2 Copyright (c) 2000, BeOpen.com. |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
3 Copyright (c) 1995-2000, Corporation for National Research Initiatives. |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
4 Copyright (c) 1990-1995, Stichting Mathematisch Centrum. |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
5 All rights reserved. |
| 1449 | 6 |
|
13255
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
7 See the file "Misc/COPYRIGHT" for information on usage and |
|
916fb024ce94
Change copyright notice.
Guido van Rossum <guido@python.org>
parents:
4503
diff
changeset
|
8 redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
| 1449 | 9 ******************************************************************/ |
| 10 | |
| 11 /* A perhaps slow but I hope correct implementation of memmove */ | |
| 12 | |
| 13 extern char *memcpy(); | |
| 14 | |
| 15 char * | |
| 16 memmove(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 } |
