1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:54:58 +00:00

LibC: Upgrade memmove() to memcpy() when possible

We were missing out on opportunities to use memcpy() instead of
memmove() when the source and destination don't overlap.
This commit is contained in:
Andreas Kling 2021-09-13 17:23:24 +02:00
parent af8732435c
commit 5b19e9239a

View file

@ -155,7 +155,7 @@ void* memset(void* dest_ptr, int c, size_t n)
void* memmove(void* dest, const void* src, size_t n)
{
if (dest < src)
if (((FlatPtr)dest - (FlatPtr)src) >= n)
return memcpy(dest, src, n);
u8* pd = (u8*)dest;