Mercurial > cpython-lru_cache-weakref
annotate Python/memmove.c @ 13658:f79434ee41fa legacy-trunk
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
declarations yet, those come later.
| author | Thomas Wouters <thomas@python.org> |
|---|---|
| date | Sat, 22 Jul 2000 18:47:25 +0000 |
| parents | 87ee82e5c56d |
| children | 6f6f965c5e2d |
| 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 | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13256
diff
changeset
|
13 extern char *memcpy(char *, char *, int); |
| 1449 | 14 |
| 15 char * | |
|
13658
f79434ee41fa
Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents:
13256
diff
changeset
|
16 memmove(char *dst, char *src, int n) |
| 1449 | 17 { |
| 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++; | |
| 26 } | |
| 27 else if (src < dst) { | |
| 28 src += n; | |
| 29 dst += n; | |
| 30 while (--n >= 0) | |
| 31 *--dst = *--src; | |
| 32 } | |
| 33 return realdst; | |
| 34 } |
