mirror of https://github.com/OpenTTD/OpenTTD
Codechange: replace memmove with std::move(_backwards)
parent
3cd040ffe9
commit
568b70e556
|
@ -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--;
|
||||
}
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue