LibC: Support backwards copy in memmove().

This commit is contained in:
Andreas Kling 2019-01-23 08:31:23 +01:00
parent 84c4110a50
commit c7ded89f05
Notes: sideshowbarker 2024-07-19 15:58:08 +09:00

View file

@ -141,8 +141,12 @@ void* memmove(void* dest, const void* src, size_t n)
{
if (dest < src)
return memcpy(dest, src, n);
// FIXME: Implement backwards copy.
assert(false);
byte *pd = (byte*)dest;
const byte *ps = (const byte*)src;
for (pd += n, ps += n; n--;)
*--pd = *--ps;
return dest;
}
char* strcpy(char* dest, const char *src)