- Fix RtlSubtreePredecessor/Successor, someone had implemented them backwards.
authorAlex Ionescu <aionescu@gmail.com>
Wed, 9 Nov 2005 01:05:00 +0000 (01:05 +0000)
committerAlex Ionescu <aionescu@gmail.com>
Wed, 9 Nov 2005 01:05:00 +0000 (01:05 +0000)
svn path=/trunk/; revision=19080

reactos/lib/rtl/splaytree.c

index 5bb38fc..7b45d8d 100644 (file)
@@ -411,49 +411,44 @@ RtlSplay(PRTL_SPLAY_LINKS Links)
        return N;
 }
 
-
 /*
 * @implemented
 */
-PRTL_SPLAY_LINKS NTAPI
-RtlSubtreePredecessor (IN PRTL_SPLAY_LINKS Links)
+PRTL_SPLAY_LINKS
+NTAPI
+RtlSubtreePredecessor(IN PRTL_SPLAY_LINKS Links)
 {
-   PRTL_SPLAY_LINKS Child;
-
-   Child = Links->RightChild;
-   if (Child == NULL)
-      return NULL;
+    PRTL_SPLAY_LINKS Child;
 
-   if (Child->LeftChild == NULL)
-      return Child;
+    /* Get the left child */
+    Child = RtlLeftChild(Links);
+    if (!Child) return NULL;
 
-   /* Get left-most child */
-   while (Child->LeftChild != NULL)
-      Child = Child->LeftChild;
+    /* Get right-most child */
+    while (RtlRightChild(Child)) Child = RtlRightChild(Child);
 
-   return Child;
+    /* Return it */
+    return Child;
 }
 
 /*
 * @implemented
 */
-PRTL_SPLAY_LINKS NTAPI
-RtlSubtreeSuccessor (IN PRTL_SPLAY_LINKS Links)
+PRTL_SPLAY_LINKS
+NTAPI
+RtlSubtreeSuccessor(IN PRTL_SPLAY_LINKS Links)
 {
-   PRTL_SPLAY_LINKS Child;
-
-   Child = Links->LeftChild;
-   if (Child == NULL)
-      return NULL;
+    PRTL_SPLAY_LINKS Child;
 
-   if (Child->RightChild == NULL)
-      return Child;
+    /* Get the right child */
+    Child = RtlRightChild(Links);
+    if (!Child) return NULL;
 
-   /* Get right-most child */
-   while (Child->RightChild != NULL)
-      Child = Child->RightChild;
+    /* Get left-most child */
+    while (RtlLeftChild(Child)) Child = RtlLeftChild(Child);
 
-   return Child;
+    /* Return it */
+    return Child;
 }
 
 /* EOF */