From b858c18208f6a35867232fdabbc7eea45b9d6ce6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 18 Oct 2014 23:59:25 +0000 Subject: [PATCH] Fix whitespace, and get rid of that sh*tty K&R style. svn path=/trunk/; revision=64819 --- reactos/lib/rtl/splaytree.c | 87 +++++++++++++++++++++---------------- 1 file changed, 50 insertions(+), 37 deletions(-) diff --git a/reactos/lib/rtl/splaytree.c b/reactos/lib/rtl/splaytree.c index e09d734d2d8..dfb77b60848 100644 --- a/reactos/lib/rtl/splaytree.c +++ b/reactos/lib/rtl/splaytree.c @@ -21,18 +21,18 @@ static VOID FixupChildLinks(PRTL_SPLAY_LINKS Links, BOOLEAN Root, BOOLEAN LeftChild) { - if (RtlLeftChild(Links)) { + if (RtlLeftChild(Links)) RtlInsertAsLeftChild(Links, RtlLeftChild(Links)); - } - if (RtlRightChild(Links)) { + + if (RtlRightChild(Links)) RtlInsertAsRightChild(Links, RtlRightChild(Links)); - } - if (!Root) { - if (LeftChild) { + + if (!Root) + { + if (LeftChild) RtlInsertAsLeftChild(RtlParent(Links), Links); - } else { + else RtlInsertAsRightChild(RtlParent(Links), Links); - } } } @@ -57,14 +57,16 @@ When Q is the immediate parent of S, Set Q's parent to S, and the proper child ptr of S to Q When Q is the root, Set S's parent to S - */ + +*/ static VOID SwapSplayLinks(PRTL_SPLAY_LINKS LinkA, PRTL_SPLAY_LINKS LinkB) { - if (RtlParent(LinkA) == LinkB || RtlIsRoot(LinkB)) { + if (RtlParent(LinkA) == LinkB || RtlIsRoot(LinkB)) + { PRTL_SPLAY_LINKS Tmp = LinkA; LinkA = LinkB; LinkB = Tmp; @@ -72,25 +74,27 @@ SwapSplayLinks(PRTL_SPLAY_LINKS LinkA, { RTL_SPLAY_LINKS Ta = *LinkA, Tb = *LinkB; - BOOLEAN RootA = RtlIsRoot(LinkA), - LeftA = RtlIsLeftChild(LinkA), - LeftB = RtlIsLeftChild(LinkB); + BOOLEAN RootA = RtlIsRoot(LinkA), + LeftA = RtlIsLeftChild(LinkA), + LeftB = RtlIsLeftChild(LinkB); + *LinkB = Ta; *LinkA = Tb; // A was parent of B is a special case: A->Parent is now B - if (RtlParent(&Tb) == LinkA) { - if (!RootA) { - if (LeftA) { + if (RtlParent(&Tb) == LinkA) + { + if (!RootA) + { + if (LeftA) RtlInsertAsLeftChild(RtlParent(&Ta), LinkB); - } else { + else RtlInsertAsRightChild(RtlParent(&Ta), LinkB); - } } - if (LeftB) { + + if (LeftB) RtlInsertAsLeftChild(LinkB, LinkA); - } else { + else RtlInsertAsRightChild(LinkB, LinkA); - } } FixupChildLinks(LinkA, FALSE, LeftB); @@ -102,8 +106,10 @@ SwapSplayLinks(PRTL_SPLAY_LINKS LinkA, #ifdef VERIFY_SWAP_SPLAY_LINKS // Verify the distinct cases of node swap - if (RootA) { - if (RtlParent(&Tb) == LinkA) { + if (RootA) + { + if (RtlParent(&Tb) == LinkA) + { // LinkA = D, LinkB = B // D B S S.L S.R S Q Q.R ASSERT(RtlParent(LinkA) == LinkB); @@ -112,7 +118,9 @@ SwapSplayLinks(PRTL_SPLAY_LINKS LinkA, ASSERT(RtlParent(LinkB) == LinkB); ASSERT(RtlLeftChild(LinkB) == (LeftB ? LinkA : RtlLeftChild(&Ta))); ASSERT(RtlRightChild(LinkB) == (LeftB ? RtlRightChild(&Ta) : LinkA)); - } else { + } + else + { // LinkA = D, LinkB = A // D A S.P S.L S.R S Q.L Q.R ASSERT(RtlParent(LinkA) == RtlParent(&Tb)); @@ -122,8 +130,11 @@ SwapSplayLinks(PRTL_SPLAY_LINKS LinkA, ASSERT(RtlLeftChild(LinkB) == RtlLeftChild(&Ta)); ASSERT(RtlRightChild(LinkB) == RtlRightChild(&Ta)); } - } else { - if (RtlParent(&Tb) == LinkA) { + } + else + { + if (RtlParent(&Tb) == LinkA) + { // LinkA = B, LinkB = A // B A S S.L S.R Q.P Q Q.R ASSERT(RtlParent(LinkA) == LinkB); @@ -132,7 +143,9 @@ SwapSplayLinks(PRTL_SPLAY_LINKS LinkA, ASSERT(RtlParent(LinkB) == RtlParent(&Ta)); ASSERT(RtlLeftChild(LinkB) == (LeftB ? LinkA : RtlLeftChild(&Ta))); ASSERT(RtlRightChild(LinkB) == (LeftB ? RtlRightChild(&Ta) : LinkA)); - } else { + } + else + { // LinkA = A, LinkB = C // A C S.P S.L S.R Q.P Q.L Q.R ASSERT(!memcmp(LinkA, &Tb, sizeof(Tb))); @@ -323,8 +336,8 @@ RtlDeleteNoSplay(PRTL_SPLAY_LINKS Links, } /* -* @implemented -*/ + * @implemented + */ PRTL_SPLAY_LINKS NTAPI RtlRealPredecessor(PRTL_SPLAY_LINKS Links) @@ -352,8 +365,8 @@ RtlRealPredecessor(PRTL_SPLAY_LINKS Links) } /* -* @implemented -*/ + * @implemented + */ PRTL_SPLAY_LINKS NTAPI RtlRealSuccessor(PRTL_SPLAY_LINKS Links) @@ -381,8 +394,8 @@ RtlRealSuccessor(PRTL_SPLAY_LINKS Links) } /* -* @implemented -*/ + * @implemented + */ PRTL_SPLAY_LINKS NTAPI RtlSplay(PRTL_SPLAY_LINKS Links) @@ -725,8 +738,8 @@ RtlSplay(PRTL_SPLAY_LINKS Links) } /* -* @implemented -*/ + * @implemented + */ PRTL_SPLAY_LINKS NTAPI RtlSubtreePredecessor(IN PRTL_SPLAY_LINKS Links) @@ -745,8 +758,8 @@ RtlSubtreePredecessor(IN PRTL_SPLAY_LINKS Links) } /* -* @implemented -*/ + * @implemented + */ PRTL_SPLAY_LINKS NTAPI RtlSubtreeSuccessor(IN PRTL_SPLAY_LINKS Links)