mirror of
https://github.com/reactos/reactos.git
synced 2025-07-12 23:34:15 +00:00
[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:
parent
9d780c6b0b
commit
768e35e84d
3 changed files with 18 additions and 13 deletions
|
@ -91,11 +91,11 @@ BOOLEAN UmaDescReserve(IN OUT PUSHORT Segment, IN OUT PUSHORT Size)
|
||||||
// FIXME: Check! What to do?
|
// FIXME: Check! What to do?
|
||||||
if (RequestSize == 0) DPRINT1("Requesting UMA descriptor with null size?!\n");
|
if (RequestSize == 0) DPRINT1("Requesting UMA descriptor with null size?!\n");
|
||||||
|
|
||||||
for (Entry = UmaDescriptorList.Flink;
|
Entry = UmaDescriptorList.Flink;
|
||||||
Entry != &UmaDescriptorList;
|
while (Entry != &UmaDescriptorList)
|
||||||
Entry = Entry->Flink)
|
|
||||||
{
|
{
|
||||||
UmaDesc = (PUMA_DESCRIPTOR)CONTAINING_RECORD(Entry, UMA_DESCRIPTOR, Entry);
|
UmaDesc = (PUMA_DESCRIPTOR)CONTAINING_RECORD(Entry, UMA_DESCRIPTOR, Entry);
|
||||||
|
Entry = Entry->Flink;
|
||||||
|
|
||||||
/* Only check free descriptors */
|
/* Only check free descriptors */
|
||||||
if (UmaDesc->Type != UMA_FREE) continue;
|
if (UmaDesc->Type != UMA_FREE) continue;
|
||||||
|
@ -209,11 +209,11 @@ BOOLEAN UmaDescRelease(IN USHORT Segment)
|
||||||
PUMA_DESCRIPTOR UmaDesc, PrevDesc = NULL, NextDesc = NULL;
|
PUMA_DESCRIPTOR UmaDesc, PrevDesc = NULL, NextDesc = NULL;
|
||||||
PUMA_DESCRIPTOR FoundUmaDesc = NULL;
|
PUMA_DESCRIPTOR FoundUmaDesc = NULL;
|
||||||
|
|
||||||
for (Entry = UmaDescriptorList.Flink;
|
Entry = UmaDescriptorList.Flink;
|
||||||
Entry != &UmaDescriptorList;
|
while (Entry != &UmaDescriptorList)
|
||||||
Entry = Entry->Flink)
|
|
||||||
{
|
{
|
||||||
UmaDesc = (PUMA_DESCRIPTOR)CONTAINING_RECORD(Entry, UMA_DESCRIPTOR, Entry);
|
UmaDesc = (PUMA_DESCRIPTOR)CONTAINING_RECORD(Entry, UMA_DESCRIPTOR, Entry);
|
||||||
|
Entry = Entry->Flink;
|
||||||
|
|
||||||
/* Search for the descriptor in the list */
|
/* Search for the descriptor in the list */
|
||||||
if (UmaDesc->Start == Address && UmaDesc->Type == UMA_UMB)
|
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?
|
// FIXME: Check! What to do?
|
||||||
if (RequestSize == 0) DPRINT1("Resizing UMA descriptor %04X to null size?!\n", Segment);
|
if (RequestSize == 0) DPRINT1("Resizing UMA descriptor %04X to null size?!\n", Segment);
|
||||||
|
|
||||||
for (Entry = UmaDescriptorList.Flink;
|
Entry = UmaDescriptorList.Flink;
|
||||||
Entry != &UmaDescriptorList;
|
while (Entry != &UmaDescriptorList)
|
||||||
Entry = Entry->Flink)
|
|
||||||
{
|
{
|
||||||
UmaDesc = (PUMA_DESCRIPTOR)CONTAINING_RECORD(Entry, UMA_DESCRIPTOR, Entry);
|
UmaDesc = (PUMA_DESCRIPTOR)CONTAINING_RECORD(Entry, UMA_DESCRIPTOR, Entry);
|
||||||
|
Entry = Entry->Flink;
|
||||||
|
|
||||||
/* Only get the maximum size of free descriptors */
|
/* Only get the maximum size of free descriptors */
|
||||||
if (UmaDesc->Type == UMA_FREE)
|
if (UmaDesc->Type == UMA_FREE)
|
||||||
|
|
|
@ -65,6 +65,7 @@ VOID ClockUpdate(VOID)
|
||||||
extern BOOLEAN CpuRunning;
|
extern BOOLEAN CpuRunning;
|
||||||
UINT i;
|
UINT i;
|
||||||
PLIST_ENTRY Entry;
|
PLIST_ENTRY Entry;
|
||||||
|
PHARDWARE_TIMER Timer;
|
||||||
|
|
||||||
while (VdmRunning && CpuRunning)
|
while (VdmRunning && CpuRunning)
|
||||||
{
|
{
|
||||||
|
@ -81,10 +82,13 @@ VOID ClockUpdate(VOID)
|
||||||
++Cycles;
|
++Cycles;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Entry = Timers.Flink; Entry != &Timers; Entry = Entry->Flink)
|
Entry = Timers.Flink;
|
||||||
|
while (Entry != &Timers)
|
||||||
{
|
{
|
||||||
ULONGLONG Ticks = (ULONGLONG)-1;
|
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));
|
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;
|
PHARDWARE_TIMER Timer;
|
||||||
|
|
||||||
Timer = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(*Timer));
|
Timer = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*Timer));
|
||||||
if (Timer == NULL) return NULL;
|
if (Timer == NULL) return NULL;
|
||||||
|
|
||||||
Timer->Flags = Flags & ~HARDWARE_TIMER_ENABLED;
|
Timer->Flags = Flags & ~HARDWARE_TIMER_ENABLED;
|
||||||
Timer->EnableCount = 0;
|
Timer->EnableCount = 0;
|
||||||
Timer->Callback = Callback;
|
Timer->Callback = Callback;
|
||||||
|
Timer->LastTick.QuadPart = 0;
|
||||||
SetHardwareTimerDelay(Timer, Delay);
|
SetHardwareTimerDelay(Timer, Delay);
|
||||||
|
|
||||||
if (Flags & HARDWARE_TIMER_ENABLED) EnableHardwareTimer(Timer);
|
if (Flags & HARDWARE_TIMER_ENABLED) EnableHardwareTimer(Timer);
|
||||||
|
|
|
@ -27,8 +27,8 @@ typedef struct _HARDWARE_TIMER
|
||||||
ULONG Flags;
|
ULONG Flags;
|
||||||
LONG EnableCount;
|
LONG EnableCount;
|
||||||
ULONGLONG Delay;
|
ULONGLONG Delay;
|
||||||
PHARDWARE_TIMER_PROC Callback;
|
|
||||||
LARGE_INTEGER LastTick;
|
LARGE_INTEGER LastTick;
|
||||||
|
PHARDWARE_TIMER_PROC Callback;
|
||||||
} HARDWARE_TIMER, *PHARDWARE_TIMER;
|
} HARDWARE_TIMER, *PHARDWARE_TIMER;
|
||||||
|
|
||||||
/* FUNCTIONS ******************************************************************/
|
/* FUNCTIONS ******************************************************************/
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue