Author: hbelusca
Date: Sat Aug 1 18:56:44 2015
New Revision: 68589
URL:
http://svn.reactos.org/svn/reactos?rev=68589&view=rev
Log:
[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.
Modified:
trunk/reactos/subsystems/mvdm/ntvdm/bios/umamgr.c
trunk/reactos/subsystems/mvdm/ntvdm/clock.c
trunk/reactos/subsystems/mvdm/ntvdm/clock.h
Modified: trunk/reactos/subsystems/mvdm/ntvdm/bios/umamgr.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/bios…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/bios/umamgr.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/bios/umamgr.c [iso-8859-1] Sat Aug 1 18:56:44
2015
@@ -91,11 +91,11 @@
// 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 @@
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 @@
// 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)
Modified: trunk/reactos/subsystems/mvdm/ntvdm/clock.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/cloc…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/clock.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/clock.c [iso-8859-1] Sat Aug 1 18:56:44 2015
@@ -65,6 +65,7 @@
extern BOOLEAN CpuRunning;
UINT i;
PLIST_ENTRY Entry;
+ PHARDWARE_TIMER Timer;
while (VdmRunning && CpuRunning)
{
@@ -81,10 +82,13 @@
++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 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);
Modified: trunk/reactos/subsystems/mvdm/ntvdm/clock.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/cloc…
==============================================================================
--- trunk/reactos/subsystems/mvdm/ntvdm/clock.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/mvdm/ntvdm/clock.h [iso-8859-1] Sat Aug 1 18:56:44 2015
@@ -27,8 +27,8 @@
ULONG Flags;
LONG EnableCount;
ULONGLONG Delay;
+ LARGE_INTEGER LastTick;
PHARDWARE_TIMER_PROC Callback;
- LARGE_INTEGER LastTick;
} HARDWARE_TIMER, *PHARDWARE_TIMER;
/* FUNCTIONS ******************************************************************/