Staging
v0.5.1
https://github.com/python/cpython
Revision 0bb8567e1e6cfe1e65ac5113945096bf2d369fa4 authored by Georg Brandl on 23 February 2008, 22:35:33 UTC, committed by Georg Brandl on 23 February 2008, 22:35:33 UTC
Originally written for GHOP by Josip Dzolonga, heavily patched by me.
1 parent c76ea27
Raw File
Tip revision: 0bb8567e1e6cfe1e65ac5113945096bf2d369fa4 authored by Georg Brandl on 23 February 2008, 22:35:33 UTC
In test_heapq and test_bisect, test both the Python and the C implementation.
Tip revision: 0bb8567
memmove.c

/* A perhaps slow but I hope correct implementation of memmove */

extern char *memcpy(char *, char *, int);

char *
memmove(char *dst, char *src, int n)
{
	char *realdst = dst;
	if (n <= 0)
		return dst;
	if (src >= dst+n || dst >= src+n)
		return memcpy(dst, src, n);
	if (src > dst) {
		while (--n >= 0)
			*dst++ = *src++;
	}
	else if (src < dst) {
		src += n;
		dst += n;
		while (--n >= 0)
			*--dst = *--src;
	}
	return realdst;
}
back to top