From e2c053a3075470dfb445fb516cc37cb266e920e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Gardou?= Date: Thu, 4 Aug 2011 18:23:20 +0000 Subject: [PATCH] [NTOSKRNL/MM] - Actually, there is no need to crawl the entire tree, just going past the limit is enough. Thanks Timo. - Fix MSVC warning, thanks Ged. Now you have correct AND optimized code, Alex AND Timo should be happy. I'm only the committer of these fix, the work was mostly done by Thomas Faber and Alex Ionescu. svn path=/trunk/; revision=53064 --- reactos/ntoskrnl/mm/ARM3/vadnode.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/reactos/ntoskrnl/mm/ARM3/vadnode.c b/reactos/ntoskrnl/mm/ARM3/vadnode.c index a3aac247bea..0d6fbd6a47c 100644 --- a/reactos/ntoskrnl/mm/ARM3/vadnode.c +++ b/reactos/ntoskrnl/mm/ARM3/vadnode.c @@ -393,10 +393,11 @@ MiFindEmptyAddressRangeDownTree(IN SIZE_T Length, /* Calculate the initial upper margin */ HighVpn = BoundaryAddress >> PAGE_SHIFT; - /* Starting from the root, go down until the right-most child, - trying to stay below the boundary. */ + /* Starting from the root, go down until the right-most child + * which is just behind the boundary*/ LowestNode = Node = RtlRightChildAvl(&Table->BalancedRoot); - while ((Child = RtlRightChildAvl(Node))) Node = Child; + while (((Child = RtlRightChildAvl(Node)) != 0 ) + && (Node->EndingVpn < HighVpn )) Node = Child; /* Now loop the Vad nodes */ while (Node)