Ruby: missing/memmove.c Source File

Ruby 3.2.5p208 (2024-07-26 revision 31d0f1a2e7dbfb60731d1f05b868e1d578cda493)

memmove.c
1/* public domain rewrite of memcmp(3) */
2
3#include "ruby/missing.h"
4#include <stddef.h>
5
6void *
7memmove(void *d, const void *s, size_t n)
8{
9 char *dst = (char *)d;
10 const char *src = (const char *)s;
11
12 if (src < dst) {
13 src += n;
14 dst += n;
15 for (; n; --n)
16 *--dst = *--src;
17 }
18 else if (dst < src)
19 for (; n; --n)
20 *dst++ = *src++;
21 return d;
22}