1
0
Fork 0

Codechange: replace memmove with std::move(_backwards)

pull/14255/head
Rubidium 2025-05-08 22:06:29 +02:00 committed by rubidium42
parent 3cd040ffe9
commit 568b70e556
4 changed files with 5 additions and 3 deletions

View File

@ -93,7 +93,7 @@ public:
{
_vals[idx].~T();
if(idx < (_size - 1)) {
memmove(static_cast<void *>(&_vals[idx]), &_vals[idx+1], sizeof(T) * (_size - (size_t)idx - 1));
std::move(&_vals[idx + 1], &_vals[_size], &_vals[idx]);
}
_size--;
}

View File

@ -49,6 +49,7 @@
#define memcmp SAFEGUARD_DO_NOT_USE_THIS_METHOD
#define memcpy SAFEGUARD_DO_NOT_USE_THIS_METHOD
#define memmove SAFEGUARD_DO_NOT_USE_THIS_METHOD
#define memset SAFEGUARD_DO_NOT_USE_THIS_METHOD
/* Use fgets instead. */

View File

@ -426,7 +426,7 @@ public:
if (IsSavegameVersionBefore(SLV_85)) {
/* We want to insert some liveries somewhere in between. This means some have to be moved. */
memmove(&c->livery[LS_FREIGHT_WAGON], &c->livery[LS_PASSENGER_WAGON_MONORAIL], (LS_END - LS_FREIGHT_WAGON) * sizeof(c->livery[0]));
std::move_backward(&c->livery[LS_FREIGHT_WAGON - 2], &c->livery[LS_END - 2], &c->livery[LS_END]);
c->livery[LS_PASSENGER_WAGON_MONORAIL] = c->livery[LS_MONORAIL];
c->livery[LS_PASSENGER_WAGON_MAGLEV] = c->livery[LS_MAGLEV];
}

View File

@ -803,7 +803,8 @@ static void CompactSpriteCache()
GetSpriteCache(i)->ptr = s->data; // Adjust sprite array entry
/* Swap this and the next block */
temp = *s;
memmove(s, next, next->size);
std::byte *p = reinterpret_cast<std::byte *>(next);
std::move(p, &p[next->size], reinterpret_cast<std::byte *>(s));
s = NextBlock(s);
*s = temp;