Skip to content

Commit c599731

Browse files
authored
Merge pull request #485 from GeneralsOnlineDevelopmentTeam/seer/refactor/gamememory-loops
refactor(gamememory): Improve clarity of memory fill loops
2 parents 3466fed + 2665fab commit c599731

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

Generals/Code/GameEngine/Source/Common/System/GameMemory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ static void memset32(void* ptr, Int value, Int bytesToFill)
303303
bytesToFill -= (wordsToFill<<2);
304304

305305
Int *p = (Int*)ptr;
306-
for (++wordsToFill; --wordsToFill; )
306+
while (wordsToFill-- > 0)
307307
*p++ = value;
308308

309309
Byte *b = (Byte *)p;
310-
for (++bytesToFill; --bytesToFill; )
310+
while (bytesToFill-- > 0)
311311
*b++ = (Byte)value;
312312
}
313313

GeneralsMD/Code/GameEngine/Source/Common/System/GameMemory.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,11 +283,11 @@ static void memset32(void* ptr, Int value, Int bytesToFill)
283283
bytesToFill -= (wordsToFill<<2);
284284

285285
Int *p = (Int*)ptr;
286-
for (++wordsToFill; --wordsToFill; )
286+
while (wordsToFill-- > 0)
287287
*p++ = value;
288288

289289
Byte *b = (Byte *)p;
290-
for (++bytesToFill; --bytesToFill; )
290+
while (bytesToFill-- > 0)
291291
*b++ = (Byte)value;
292292
}
293293

0 commit comments

Comments
 (0)