1 /* 2 FUNCTION 3 <<memmove>>---move possibly overlapping memory 4 5 INDEX 6 memmove 7 8 ANSI_SYNOPSIS 9 #include <string.h> 10 void *memmove(void *<[dst]>, const void *<[src]>, size_t <[length]>); 11 12 TRAD_SYNOPSIS 13 #include <string.h> 14 void *memmove(<[dst]>, <[src]>, <[length]>) 15 void *<[dst]>; 16 void *<[src]>; 17 size_t <[length]>; 18 19 DESCRIPTION 20 This function moves <[length]> characters from the block of 21 memory starting at <<*<[src]>>> to the memory starting at 22 <<*<[dst]>>>. <<memmove>> reproduces the characters correctly 23 at <<*<[dst]>>> even if the two areas overlap. 24 25 26 RETURNS 27 The function returns <[dst]> as passed. 28 29 PORTABILITY 30 <<memmove>> is ANSI C. 31 32 <<memmove>> requires no supporting OS subroutines. 33 34 QUICKREF 35 memmove ansi pure 36 */ 37 38 void* 39 memmove (void *dst_void, const void *src_void, long length) 40 { 41 char *dst = dst_void; 42 const char *src = src_void; 43 44 if (src < dst && dst < src + length) 45 { 46 /* Have to copy backwards */ 47 src += length; 48 dst += length; 49 while (length--) 50 { 51 *--dst = *--src; 52 } 53 } 54 else 55 { 56 while (length--) 57 { 58 *dst++ = *src++; 59 } 60 } 61 62 return dst_void; 63 }