Fix ulib's memmove to handle overlap when src<dst

This commit is contained in:
Anish Athalye 2019-10-08 21:24:03 -04:00
parent 8509784d80
commit f2df0fa547

View file

@ -103,8 +103,15 @@ memmove(void *vdst, const void *vsrc, int n)
dst = vdst;
src = vsrc;
if (src > dst) {
while(n-- > 0)
*dst++ = *src++;
} else {
dst += n;
src += n;
while(n-- > 0)
*--dst = *--src;
}
return vdst;
}