mirror of
https://github.com/fluencelabs/musl
synced 2025-06-26 21:22:11 +00:00
this commit introduces a performance regression in many uses of memmove, which will need to be addressed before the next release. i'm making it as a temporary measure so that the restrict patch can be committed without invoking undefined behavior when memmove calls memcpy with overlapping regions.
14 lines
236 B
C
14 lines
236 B
C
#include <string.h>
|
|
|
|
void *memmove(void *dest, const void *src, size_t n)
|
|
{
|
|
char *d = dest;
|
|
const char *s = src;
|
|
if (d==s) return d;
|
|
if ((size_t)(d-s) < n)
|
|
while (n--) d[n] = s[n];
|
|
else
|
|
while (n--) *d++ = *s++;
|
|
return dest;
|
|
}
|