1/* memmove.c -- copy memory. 2 Copy LENGTH bytes from SOURCE to DEST. Does not null-terminate. 3 In the public domain. 4 By David MacKenzie <djm@gnu.ai.mit.edu>. */ 5 6#if HAVE_CONFIG_H 7# include <config.h> 8#endif 9 10void * 11memmove (char *dest, const char *source, unsigned length) 12{ 13 char *d0 = dest; 14 if (source < dest) 15 /* Moving from low mem to hi mem; start at end. */ 16 for (source += length, dest += length; length; --length) 17 *--dest = *--source; 18 else if (source != dest) 19 { 20 /* Moving from hi mem to low mem; start at beginning. */ 21 for (; length; --length) 22 *dest++ = *source++; 23 } 24 return (void *) d0; 25} 26