MCPcopy Index your code
hub / github.com/dcodeIO/webassembly / memmove

Function memmove

lib/memmove.c:29–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27#define WS (sizeof(WT))
28
29void *memmove(void *dest, const void *src, size_t n)
30{
31 char *d = dest;
32 const char *s = src;
33
34 if (d==s) return d;
35 if (s+n <= d || d+n <= s) return memcpy(d, s, n);
36
37 if (d<s) {
38 if ((uintptr_t)s % WS == (uintptr_t)d % WS) {
39 while ((uintptr_t)d % WS) {
40 if (!n--) return dest;
41 *d++ = *s++;
42 }
43 for (; n>=WS; n-=WS, d+=WS, s+=WS) *(WT *)d = *(WT *)s;
44 }
45 for (; n; n--) *d++ = *s++;
46 } else {
47 if ((uintptr_t)s % WS == (uintptr_t)d % WS) {
48 while ((uintptr_t)(d+n) % WS) {
49 if (!n--) return dest;
50 d[n] = s[n];
51 }
52 while (n>=WS) n-=WS, *(WT *)(d+n) = *(WT *)(s+n);
53 }
54 while (n) n--, d[n] = s[n];
55 }
56
57 return dest;
58}

Callers

nothing calls this directly

Calls 1

memcpyFunction · 0.85

Tested by

no test coverage detected