Ruby  2.0.0p247(2013-06-27revision41674)
missing/memmove.c
Go to the documentation of this file.
00001 /* public domain rewrite of memcmp(3) */
00002 
00003 #include "ruby/missing.h"
00004 #include <stddef.h>
00005 
00006 void *
00007 memmove(void *d, const void *s, size_t n)
00008 {
00009     char *dst = (char *)d;
00010     const char *src = (const char *)s;
00011 
00012     if (src < dst) {
00013         src += n;
00014         dst += n;
00015         for (; n; --n)
00016             *--dst = *--src;
00017     }
00018     else if (dst < src)
00019         for (; n; --n)
00020             *dst++ = *src++;
00021     return d;
00022 }
00023