1 /* 2 * Copyright (C) 1991, 1992 Linus Torvalds 3 */ 4 5 #include <xen/string.h> 6 7 /** 8 * memmove - Copy one area of memory to another 9 * @dest: Where to copy to 10 * @src: Where to copy from 11 * @n: The size of the area. 12 * 13 * Unlike memcpy(), memmove() copes with overlapping areas. 14 */ 15 void *(memmove)(void *dest, const void *src, size_t n) 16 { 17 char *tmp, *s; 18 19 if (dest <= src) { 20 tmp = (char *) dest; 21 s = (char *) src; 22 while (n--) 23 *tmp++ = *s++; 24 } else { 25 tmp = (char *) dest + n; 26 s = (char *) src + n; 27 while (n--) 28 *--tmp = *--s; 29 } 30 31 return dest; 32 } 33 34 /* 35 * Local variables: 36 * mode: C 37 * c-file-style: "BSD" 38 * c-basic-offset: 8 39 * tab-width: 8 40 * indent-tabs-mode: t 41 * End: 42 */ 43