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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1449
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
9 ******************************************************************/
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
10
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 /* A perhaps slow but I hope correct implementation of memmove */
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
14
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
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
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
17 {
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
18 char *realdst = dst;
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
19 if (n <= 0)
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
20 return dst;
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
21 if (src >= dst+n || dst >= src+n)
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
22 return memcpy(dst, src, n);
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
23 if (src > dst) {
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
24 while (--n >= 0)
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
25 *dst++ = *src++;
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
26 }
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
27 else if (src < dst) {
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
28 src += n;
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
29 dst += n;
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
30 while (--n >= 0)
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
31 *--dst = *--src;
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
32 }
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
33 return realdst;
ae93ec4dd556 New files.
Guido van Rossum <guido@python.org>
parents:
diff changeset
34 }