shithub: scc

ref: 9e2ce8d610b9eacac34979540ed8f6dea47b0ed2
dir: /libc/src/memmove.c/

View raw version
/* See LICENSE file for copyright and license details. */

#include <string.h>

void *
memmove(void *dst, const void *src, size_t n)
{
	char *d = dst, *s = (char *) src;

	if (d < s) {
		while (n-- > 0)
			*d++ = *s++;
	} else {
		s += n-1, d += n-1;
		while (n-- > 0)
			*d-- = *s--;
	}
	return dst;
}