[NTVDM]: Use the while() construct for looping into doubly-linked lists where we can remove items from it in the middle of the loop code.

svn path=/trunk/; revision=68589
This commit is contained in:
Hermès Bélusca-Maïto 2015-08-01 18:56:44 +00:00
parent 9d780c6b0b
commit 768e35e84d
3 changed files with 18 additions and 13 deletions

View file

@ -91,11 +91,11 @@ BOOLEAN UmaDescReserve(IN OUT PUSHORT Segment, IN OUT PUSHORT Size)
// FIXME: Check! What to do?
if (RequestSize == 0) DPRINT1("Requesting UMA descriptor with null size?!\n");
for (Entry = UmaDescriptorList.Flink;
Entry != &UmaDescriptorList;
Entry = Entry->Flink)
Entry = UmaDescriptorList.Flink;
while (Entry != &UmaDescriptorList)
{
UmaDesc = (PUMA_DESCRIPTOR)CONTAINING_RECORD(Entry, UMA_DESCRIPTOR, Entry);
Entry = Entry->Flink;
/* Only check free descriptors */
if (UmaDesc->Type != UMA_FREE) continue;
@ -209,11 +209,11 @@ BOOLEAN UmaDescRelease(IN USHORT Segment)
PUMA_DESCRIPTOR UmaDesc, PrevDesc = NULL, NextDesc = NULL;
PUMA_DESCRIPTOR FoundUmaDesc = NULL;
for (Entry = UmaDescriptorList.Flink;
Entry != &UmaDescriptorList;
Entry = Entry->Flink)
Entry = UmaDescriptorList.Flink;
while (Entry != &UmaDescriptorList)
{
UmaDesc = (PUMA_DESCRIPTOR)CONTAINING_RECORD(Entry, UMA_DESCRIPTOR, Entry);
Entry = Entry->Flink;
/* Search for the descriptor in the list */
if (UmaDesc->Start == Address && UmaDesc->Type == UMA_UMB)
@ -267,11 +267,11 @@ BOOLEAN UmaDescReallocate(IN USHORT Segment, IN OUT PUSHORT Size)
// FIXME: Check! What to do?
if (RequestSize == 0) DPRINT1("Resizing UMA descriptor %04X to null size?!\n", Segment);
for (Entry = UmaDescriptorList.Flink;
Entry != &UmaDescriptorList;
Entry = Entry->Flink)
Entry = UmaDescriptorList.Flink;
while (Entry != &UmaDescriptorList)
{
UmaDesc = (PUMA_DESCRIPTOR)CONTAINING_RECORD(Entry, UMA_DESCRIPTOR, Entry);
Entry = Entry->Flink;
/* Only get the maximum size of free descriptors */
if (UmaDesc->Type == UMA_FREE)

View file

@ -65,6 +65,7 @@ VOID ClockUpdate(VOID)
extern BOOLEAN CpuRunning;
UINT i;
PLIST_ENTRY Entry;
PHARDWARE_TIMER Timer;
while (VdmRunning && CpuRunning)
{
@ -81,10 +82,13 @@ VOID ClockUpdate(VOID)
++Cycles;
}
for (Entry = Timers.Flink; Entry != &Timers; Entry = Entry->Flink)
Entry = Timers.Flink;
while (Entry != &Timers)
{
ULONGLONG Ticks = (ULONGLONG)-1;
PHARDWARE_TIMER Timer = CONTAINING_RECORD(Entry, HARDWARE_TIMER, Link);
Timer = CONTAINING_RECORD(Entry, HARDWARE_TIMER, Link);
Entry = Entry->Flink;
ASSERT((Timer->EnableCount > 0) && (Timer->Flags & HARDWARE_TIMER_ENABLED));
@ -128,12 +132,13 @@ PHARDWARE_TIMER CreateHardwareTimer(ULONG Flags, ULONGLONG Delay, PHARDWARE_TIME
{
PHARDWARE_TIMER Timer;
Timer = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(*Timer));
Timer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*Timer));
if (Timer == NULL) return NULL;
Timer->Flags = Flags & ~HARDWARE_TIMER_ENABLED;
Timer->EnableCount = 0;
Timer->Callback = Callback;
Timer->LastTick.QuadPart = 0;
SetHardwareTimerDelay(Timer, Delay);
if (Flags & HARDWARE_TIMER_ENABLED) EnableHardwareTimer(Timer);

View file

@ -27,8 +27,8 @@ typedef struct _HARDWARE_TIMER
ULONG Flags;
LONG EnableCount;
ULONGLONG Delay;
PHARDWARE_TIMER_PROC Callback;
LARGE_INTEGER LastTick;
PHARDWARE_TIMER_PROC Callback;
} HARDWARE_TIMER, *PHARDWARE_TIMER;
/* FUNCTIONS ******************************************************************/