Staging
v0.5.1
https://github.com/python/cpython
Revision d254ca8813986ac72f39fdac90fdf8f63904c28e authored by Martin v. Löwis on 02 March 2008, 20:32:57 UTC, committed by Martin v. Löwis on 02 March 2008, 20:32:57 UTC
Added checks for integer overflows, contributed by Google. Some are
only available if asserts are left in the code, in cases where they
can't be triggered from Python code.
1 parent 80bdb48
Raw File
Tip revision: d254ca8813986ac72f39fdac90fdf8f63904c28e authored by Martin v. Löwis on 02 March 2008, 20:32:57 UTC
Backport of r61180:
Tip revision: d254ca8
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