]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.c
MdePkg: Apply uncrustify changes
[mirror_edk2.git] / MdePkg / Library / BaseOrderedCollectionRedBlackTreeLib / BaseOrderedCollectionRedBlackTreeLib.c
index 650a761480287d30edddcb50a5c399da892568de..f47301de8982886e8526adf9bf5b4f9ffb2b67fa 100644 (file)
@@ -30,26 +30,25 @@ typedef enum {
 // header. Beside completing the types, we introduce typedefs here that reflect\r
 // the implementation closely.\r
 //\r
-typedef ORDERED_COLLECTION              RED_BLACK_TREE;\r
-typedef ORDERED_COLLECTION_ENTRY        RED_BLACK_TREE_NODE;\r
-typedef ORDERED_COLLECTION_USER_COMPARE RED_BLACK_TREE_USER_COMPARE;\r
-typedef ORDERED_COLLECTION_KEY_COMPARE  RED_BLACK_TREE_KEY_COMPARE;\r
+typedef ORDERED_COLLECTION               RED_BLACK_TREE;\r
+typedef ORDERED_COLLECTION_ENTRY         RED_BLACK_TREE_NODE;\r
+typedef ORDERED_COLLECTION_USER_COMPARE  RED_BLACK_TREE_USER_COMPARE;\r
+typedef ORDERED_COLLECTION_KEY_COMPARE   RED_BLACK_TREE_KEY_COMPARE;\r
 \r
 struct ORDERED_COLLECTION {\r
-  RED_BLACK_TREE_NODE         *Root;\r
-  RED_BLACK_TREE_USER_COMPARE UserStructCompare;\r
-  RED_BLACK_TREE_KEY_COMPARE  KeyCompare;\r
+  RED_BLACK_TREE_NODE            *Root;\r
+  RED_BLACK_TREE_USER_COMPARE    UserStructCompare;\r
+  RED_BLACK_TREE_KEY_COMPARE     KeyCompare;\r
 };\r
 \r
 struct ORDERED_COLLECTION_ENTRY {\r
-  VOID                 *UserStruct;\r
-  RED_BLACK_TREE_NODE  *Parent;\r
-  RED_BLACK_TREE_NODE  *Left;\r
-  RED_BLACK_TREE_NODE  *Right;\r
-  RED_BLACK_TREE_COLOR Color;\r
+  VOID                    *UserStruct;\r
+  RED_BLACK_TREE_NODE     *Parent;\r
+  RED_BLACK_TREE_NODE     *Left;\r
+  RED_BLACK_TREE_NODE     *Right;\r
+  RED_BLACK_TREE_COLOR    Color;\r
 };\r
 \r
-\r
 /**\r
   Retrieve the user structure linked by the specified tree node.\r
 \r
@@ -64,7 +63,7 @@ struct ORDERED_COLLECTION_ENTRY {
 VOID *\r
 EFIAPI\r
 OrderedCollectionUserStruct (\r
-  IN CONST RED_BLACK_TREE_NODE *Node\r
+  IN CONST RED_BLACK_TREE_NODE  *Node\r
   )\r
 {\r
   return Node->UserStruct;\r
@@ -83,10 +82,9 @@ OrderedCollectionUserStruct (
 **/\r
 VOID\r
 RedBlackTreeValidate (\r
-  IN CONST RED_BLACK_TREE *Tree\r
+  IN CONST RED_BLACK_TREE  *Tree\r
   );\r
 \r
-\r
 /**\r
   Allocate and initialize the RED_BLACK_TREE structure.\r
 \r
@@ -109,11 +107,11 @@ RedBlackTreeValidate (
 RED_BLACK_TREE *\r
 EFIAPI\r
 OrderedCollectionInit (\r
-  IN RED_BLACK_TREE_USER_COMPARE UserStructCompare,\r
-  IN RED_BLACK_TREE_KEY_COMPARE  KeyCompare\r
+  IN RED_BLACK_TREE_USER_COMPARE  UserStructCompare,\r
+  IN RED_BLACK_TREE_KEY_COMPARE   KeyCompare\r
   )\r
 {\r
-  RED_BLACK_TREE *Tree;\r
+  RED_BLACK_TREE  *Tree;\r
 \r
   Tree = AllocatePool (sizeof *Tree);\r
   if (Tree == NULL) {\r
@@ -127,10 +125,10 @@ OrderedCollectionInit (
   if (FeaturePcdGet (PcdValidateOrderedCollection)) {\r
     RedBlackTreeValidate (Tree);\r
   }\r
+\r
   return Tree;\r
 }\r
 \r
-\r
 /**\r
   Check whether the tree is empty (has no nodes).\r
 \r
@@ -145,13 +143,12 @@ OrderedCollectionInit (
 BOOLEAN\r
 EFIAPI\r
 OrderedCollectionIsEmpty (\r
-  IN CONST RED_BLACK_TREE *Tree\r
+  IN CONST RED_BLACK_TREE  *Tree\r
   )\r
 {\r
   return (BOOLEAN)(Tree->Root == NULL);\r
 }\r
 \r
-\r
 /**\r
   Uninitialize and release an empty RED_BLACK_TREE structure.\r
 \r
@@ -167,14 +164,13 @@ OrderedCollectionIsEmpty (
 VOID\r
 EFIAPI\r
 OrderedCollectionUninit (\r
-  IN RED_BLACK_TREE *Tree\r
+  IN RED_BLACK_TREE  *Tree\r
   )\r
 {\r
   ASSERT (OrderedCollectionIsEmpty (Tree));\r
   FreePool (Tree);\r
 }\r
 \r
-\r
 /**\r
   Look up the tree node that links the user structure that matches the\r
   specified standalone key.\r
@@ -195,26 +191,27 @@ OrderedCollectionUninit (
 RED_BLACK_TREE_NODE *\r
 EFIAPI\r
 OrderedCollectionFind (\r
-  IN CONST RED_BLACK_TREE *Tree,\r
-  IN CONST VOID           *StandaloneKey\r
+  IN CONST RED_BLACK_TREE  *Tree,\r
+  IN CONST VOID            *StandaloneKey\r
   )\r
 {\r
-  RED_BLACK_TREE_NODE *Node;\r
+  RED_BLACK_TREE_NODE  *Node;\r
 \r
   Node = Tree->Root;\r
   while (Node != NULL) {\r
-    INTN Result;\r
+    INTN  Result;\r
 \r
     Result = Tree->KeyCompare (StandaloneKey, Node->UserStruct);\r
     if (Result == 0) {\r
       break;\r
     }\r
+\r
     Node = (Result < 0) ? Node->Left : Node->Right;\r
   }\r
+\r
   return Node;\r
 }\r
 \r
-\r
 /**\r
   Find the tree node of the minimum user structure stored in the tree.\r
 \r
@@ -231,22 +228,23 @@ OrderedCollectionFind (
 RED_BLACK_TREE_NODE *\r
 EFIAPI\r
 OrderedCollectionMin (\r
-  IN CONST RED_BLACK_TREE *Tree\r
+  IN CONST RED_BLACK_TREE  *Tree\r
   )\r
 {\r
-  RED_BLACK_TREE_NODE *Node;\r
+  RED_BLACK_TREE_NODE  *Node;\r
 \r
   Node = Tree->Root;\r
   if (Node == NULL) {\r
     return NULL;\r
   }\r
+\r
   while (Node->Left != NULL) {\r
     Node = Node->Left;\r
   }\r
+\r
   return Node;\r
 }\r
 \r
-\r
 /**\r
   Find the tree node of the maximum user structure stored in the tree.\r
 \r
@@ -263,22 +261,23 @@ OrderedCollectionMin (
 RED_BLACK_TREE_NODE *\r
 EFIAPI\r
 OrderedCollectionMax (\r
-  IN CONST RED_BLACK_TREE *Tree\r
+  IN CONST RED_BLACK_TREE  *Tree\r
   )\r
 {\r
-  RED_BLACK_TREE_NODE *Node;\r
+  RED_BLACK_TREE_NODE  *Node;\r
 \r
   Node = Tree->Root;\r
   if (Node == NULL) {\r
     return NULL;\r
   }\r
+\r
   while (Node->Right != NULL) {\r
     Node = Node->Right;\r
   }\r
+\r
   return Node;\r
 }\r
 \r
-\r
 /**\r
   Get the tree node of the least user structure that is greater than the one\r
   linked by Node.\r
@@ -296,11 +295,11 @@ OrderedCollectionMax (
 RED_BLACK_TREE_NODE *\r
 EFIAPI\r
 OrderedCollectionNext (\r
-  IN CONST RED_BLACK_TREE_NODE *Node\r
+  IN CONST RED_BLACK_TREE_NODE  *Node\r
   )\r
 {\r
-  RED_BLACK_TREE_NODE       *Walk;\r
-  CONST RED_BLACK_TREE_NODE *Child;\r
+  RED_BLACK_TREE_NODE        *Walk;\r
+  CONST RED_BLACK_TREE_NODE  *Child;\r
 \r
   if (Node == NULL) {\r
     return NULL;\r
@@ -315,6 +314,7 @@ OrderedCollectionNext (
     while (Walk->Left != NULL) {\r
       Walk = Walk->Left;\r
     }\r
+\r
     return Walk;\r
   }\r
 \r
@@ -323,15 +323,15 @@ OrderedCollectionNext (
   // ascending to the left).\r
   //\r
   Child = Node;\r
-  Walk = Child->Parent;\r
+  Walk  = Child->Parent;\r
   while (Walk != NULL && Child == Walk->Right) {\r
     Child = Walk;\r
-    Walk = Child->Parent;\r
+    Walk  = Child->Parent;\r
   }\r
+\r
   return Walk;\r
 }\r
 \r
-\r
 /**\r
   Get the tree node of the greatest user structure that is less than the one\r
   linked by Node.\r
@@ -349,11 +349,11 @@ OrderedCollectionNext (
 RED_BLACK_TREE_NODE *\r
 EFIAPI\r
 OrderedCollectionPrev (\r
-  IN CONST RED_BLACK_TREE_NODE *Node\r
+  IN CONST RED_BLACK_TREE_NODE  *Node\r
   )\r
 {\r
-  RED_BLACK_TREE_NODE       *Walk;\r
-  CONST RED_BLACK_TREE_NODE *Child;\r
+  RED_BLACK_TREE_NODE        *Walk;\r
+  CONST RED_BLACK_TREE_NODE  *Child;\r
 \r
   if (Node == NULL) {\r
     return NULL;\r
@@ -368,6 +368,7 @@ OrderedCollectionPrev (
     while (Walk->Right != NULL) {\r
       Walk = Walk->Right;\r
     }\r
+\r
     return Walk;\r
   }\r
 \r
@@ -376,15 +377,15 @@ OrderedCollectionPrev (
   // ascending to the right).\r
   //\r
   Child = Node;\r
-  Walk = Child->Parent;\r
+  Walk  = Child->Parent;\r
   while (Walk != NULL && Child == Walk->Left) {\r
     Child = Walk;\r
-    Walk = Child->Parent;\r
+    Walk  = Child->Parent;\r
   }\r
+\r
   return Walk;\r
 }\r
 \r
-\r
 /**\r
   Rotate tree nodes around Pivot to the right.\r
 \r
@@ -419,13 +420,13 @@ OrderedCollectionPrev (
 **/\r
 VOID\r
 RedBlackTreeRotateRight (\r
-  IN OUT RED_BLACK_TREE_NODE *Pivot,\r
-  OUT    RED_BLACK_TREE_NODE **NewRoot\r
+  IN OUT RED_BLACK_TREE_NODE  *Pivot,\r
+  OUT    RED_BLACK_TREE_NODE  **NewRoot\r
   )\r
 {\r
-  RED_BLACK_TREE_NODE *Parent;\r
-  RED_BLACK_TREE_NODE *LeftChild;\r
-  RED_BLACK_TREE_NODE *LeftRightChild;\r
+  RED_BLACK_TREE_NODE  *Parent;\r
+  RED_BLACK_TREE_NODE  *LeftChild;\r
+  RED_BLACK_TREE_NODE  *LeftRightChild;\r
 \r
   Parent         = Pivot->Parent;\r
   LeftChild      = Pivot->Left;\r
@@ -435,6 +436,7 @@ RedBlackTreeRotateRight (
   if (LeftRightChild != NULL) {\r
     LeftRightChild->Parent = Pivot;\r
   }\r
+\r
   LeftChild->Parent = Parent;\r
   if (Parent == NULL) {\r
     *NewRoot = LeftChild;\r
@@ -445,11 +447,11 @@ RedBlackTreeRotateRight (
       Parent->Right = LeftChild;\r
     }\r
   }\r
+\r
   LeftChild->Right = Pivot;\r
-  Pivot->Parent = LeftChild;\r
+  Pivot->Parent    = LeftChild;\r
 }\r
 \r
-\r
 /**\r
   Rotate tree nodes around Pivot to the left.\r
 \r
@@ -484,13 +486,13 @@ RedBlackTreeRotateRight (
 **/\r
 VOID\r
 RedBlackTreeRotateLeft (\r
-  IN OUT RED_BLACK_TREE_NODE *Pivot,\r
-  OUT    RED_BLACK_TREE_NODE **NewRoot\r
+  IN OUT RED_BLACK_TREE_NODE  *Pivot,\r
+  OUT    RED_BLACK_TREE_NODE  **NewRoot\r
   )\r
 {\r
-  RED_BLACK_TREE_NODE *Parent;\r
-  RED_BLACK_TREE_NODE *RightChild;\r
-  RED_BLACK_TREE_NODE *RightLeftChild;\r
+  RED_BLACK_TREE_NODE  *Parent;\r
+  RED_BLACK_TREE_NODE  *RightChild;\r
+  RED_BLACK_TREE_NODE  *RightLeftChild;\r
 \r
   Parent         = Pivot->Parent;\r
   RightChild     = Pivot->Right;\r
@@ -500,6 +502,7 @@ RedBlackTreeRotateLeft (
   if (RightLeftChild != NULL) {\r
     RightLeftChild->Parent = Pivot;\r
   }\r
+\r
   RightChild->Parent = Parent;\r
   if (Parent == NULL) {\r
     *NewRoot = RightChild;\r
@@ -510,11 +513,11 @@ RedBlackTreeRotateLeft (
       Parent->Right = RightChild;\r
     }\r
   }\r
+\r
   RightChild->Left = Pivot;\r
-  Pivot->Parent = RightChild;\r
+  Pivot->Parent    = RightChild;\r
 }\r
 \r
-\r
 /**\r
   Insert (link) a user structure into the tree.\r
 \r
@@ -579,18 +582,18 @@ RedBlackTreeRotateLeft (
 RETURN_STATUS\r
 EFIAPI\r
 OrderedCollectionInsert (\r
-  IN OUT RED_BLACK_TREE      *Tree,\r
-  OUT    RED_BLACK_TREE_NODE **Node      OPTIONAL,\r
-  IN     VOID                *UserStruct\r
+  IN OUT RED_BLACK_TREE       *Tree,\r
+  OUT    RED_BLACK_TREE_NODE  **Node      OPTIONAL,\r
+  IN     VOID                 *UserStruct\r
   )\r
 {\r
-  RED_BLACK_TREE_NODE *Tmp;\r
-  RED_BLACK_TREE_NODE *Parent;\r
-  INTN                Result;\r
-  RETURN_STATUS       Status;\r
-  RED_BLACK_TREE_NODE *NewRoot;\r
+  RED_BLACK_TREE_NODE  *Tmp;\r
+  RED_BLACK_TREE_NODE  *Parent;\r
+  INTN                 Result;\r
+  RETURN_STATUS        Status;\r
+  RED_BLACK_TREE_NODE  *NewRoot;\r
 \r
-  Tmp = Tree->Root;\r
+  Tmp    = Tree->Root;\r
   Parent = NULL;\r
   Result = 0;\r
 \r
@@ -603,14 +606,16 @@ OrderedCollectionInsert (
     if (Result == 0) {\r
       break;\r
     }\r
+\r
     Parent = Tmp;\r
-    Tmp = (Result < 0) ? Tmp->Left : Tmp->Right;\r
+    Tmp    = (Result < 0) ? Tmp->Left : Tmp->Right;\r
   }\r
 \r
   if (Tmp != NULL) {\r
     if (Node != NULL) {\r
       *Node = Tmp;\r
     }\r
+\r
     Status = RETURN_ALREADY_STARTED;\r
     goto Done;\r
   }\r
@@ -623,6 +628,7 @@ OrderedCollectionInsert (
     Status = RETURN_OUT_OF_RESOURCES;\r
     goto Done;\r
   }\r
+\r
   if (Node != NULL) {\r
     *Node = Tmp;\r
   }\r
@@ -637,19 +643,21 @@ OrderedCollectionInsert (
   // If there's no parent, the new node is the root node in the tree.\r
   //\r
   Tmp->Parent = Parent;\r
-  Tmp->Left = NULL;\r
-  Tmp->Right = NULL;\r
+  Tmp->Left   = NULL;\r
+  Tmp->Right  = NULL;\r
   if (Parent == NULL) {\r
     Tree->Root = Tmp;\r
     Tmp->Color = RedBlackTreeBlack;\r
-    Status = RETURN_SUCCESS;\r
+    Status     = RETURN_SUCCESS;\r
     goto Done;\r
   }\r
+\r
   if (Result < 0) {\r
     Parent->Left = Tmp;\r
   } else {\r
     Parent->Right = Tmp;\r
   }\r
+\r
   Tmp->Color = RedBlackTreeRed;\r
 \r
   //\r
@@ -674,8 +682,8 @@ OrderedCollectionInsert (
 \r
   NewRoot = Tree->Root;\r
   while (Tmp != NewRoot && Parent->Color == RedBlackTreeRed) {\r
-    RED_BLACK_TREE_NODE *GrandParent;\r
-    RED_BLACK_TREE_NODE *Uncle;\r
+    RED_BLACK_TREE_NODE  *GrandParent;\r
+    RED_BLACK_TREE_NODE  *Uncle;\r
 \r
     //\r
     // Tmp is not the root node. Tmp is red. Tmp's parent is red. (Breaking\r
@@ -691,7 +699,7 @@ OrderedCollectionInsert (
 \r
     if (Parent == GrandParent->Left) {\r
       Uncle = GrandParent->Right;\r
-      if (Uncle != NULL && Uncle->Color == RedBlackTreeRed) {\r
+      if ((Uncle != NULL) && (Uncle->Color == RedBlackTreeRed)) {\r
         //\r
         //             GrandParent (black)\r
         //            /                   \_\r
@@ -700,8 +708,8 @@ OrderedCollectionInsert (
         //  Tmp (red)\r
         //\r
 \r
-        Parent->Color = RedBlackTreeBlack;\r
-        Uncle->Color = RedBlackTreeBlack;\r
+        Parent->Color      = RedBlackTreeBlack;\r
+        Uncle->Color       = RedBlackTreeBlack;\r
         GrandParent->Color = RedBlackTreeRed;\r
 \r
         //\r
@@ -720,7 +728,7 @@ OrderedCollectionInsert (
         // and we will have broken property #5, by coloring the root red. We'll\r
         // restore property #5 after the loop, without breaking any others.\r
         //\r
-        Tmp = GrandParent;\r
+        Tmp    = GrandParent;\r
         Parent = Tmp->Parent;\r
       } else {\r
         //\r
@@ -759,7 +767,7 @@ OrderedCollectionInsert (
           ASSERT (GrandParent == Parent->Parent);\r
         }\r
 \r
-        Parent->Color = RedBlackTreeBlack;\r
+        Parent->Color      = RedBlackTreeBlack;\r
         GrandParent->Color = RedBlackTreeRed;\r
 \r
         //\r
@@ -794,12 +802,12 @@ OrderedCollectionInsert (
       // Symmetrical to the other branch.\r
       //\r
       Uncle = GrandParent->Left;\r
-      if (Uncle != NULL && Uncle->Color == RedBlackTreeRed) {\r
-        Parent->Color = RedBlackTreeBlack;\r
-        Uncle->Color = RedBlackTreeBlack;\r
+      if ((Uncle != NULL) && (Uncle->Color == RedBlackTreeRed)) {\r
+        Parent->Color      = RedBlackTreeBlack;\r
+        Uncle->Color       = RedBlackTreeBlack;\r
         GrandParent->Color = RedBlackTreeRed;\r
-        Tmp = GrandParent;\r
-        Parent = Tmp->Parent;\r
+        Tmp                = GrandParent;\r
+        Parent             = Tmp->Parent;\r
       } else {\r
         if (Tmp == Parent->Left) {\r
           Tmp = Parent;\r
@@ -807,7 +815,8 @@ OrderedCollectionInsert (
           Parent = Tmp->Parent;\r
           ASSERT (GrandParent == Parent->Parent);\r
         }\r
-        Parent->Color = RedBlackTreeBlack;\r
+\r
+        Parent->Color      = RedBlackTreeBlack;\r
         GrandParent->Color = RedBlackTreeRed;\r
         RedBlackTreeRotateLeft (GrandParent, &NewRoot);\r
       }\r
@@ -815,17 +824,17 @@ OrderedCollectionInsert (
   }\r
 \r
   NewRoot->Color = RedBlackTreeBlack;\r
-  Tree->Root = NewRoot;\r
-  Status = RETURN_SUCCESS;\r
+  Tree->Root     = NewRoot;\r
+  Status         = RETURN_SUCCESS;\r
 \r
 Done:\r
   if (FeaturePcdGet (PcdValidateOrderedCollection)) {\r
     RedBlackTreeValidate (Tree);\r
   }\r
+\r
   return Status;\r
 }\r
 \r
-\r
 /**\r
   Check if a node is black, allowing for leaf nodes (see property #2).\r
 \r
@@ -837,13 +846,12 @@ Done:
 **/\r
 BOOLEAN\r
 NodeIsNullOrBlack (\r
-  IN CONST RED_BLACK_TREE_NODE *Node\r
+  IN CONST RED_BLACK_TREE_NODE  *Node\r
   )\r
 {\r
   return (BOOLEAN)(Node == NULL || Node->Color == RedBlackTreeBlack);\r
 }\r
 \r
-\r
 /**\r
   Delete a node from the tree, unlinking the associated user structure.\r
 \r
@@ -912,18 +920,18 @@ NodeIsNullOrBlack (
 VOID\r
 EFIAPI\r
 OrderedCollectionDelete (\r
-  IN OUT RED_BLACK_TREE      *Tree,\r
-  IN     RED_BLACK_TREE_NODE *Node,\r
-  OUT    VOID                **UserStruct OPTIONAL\r
+  IN OUT RED_BLACK_TREE       *Tree,\r
+  IN     RED_BLACK_TREE_NODE  *Node,\r
+  OUT    VOID                 **UserStruct OPTIONAL\r
   )\r
 {\r
-  RED_BLACK_TREE_NODE  *NewRoot;\r
-  RED_BLACK_TREE_NODE  *OrigLeftChild;\r
-  RED_BLACK_TREE_NODE  *OrigRightChild;\r
-  RED_BLACK_TREE_NODE  *OrigParent;\r
-  RED_BLACK_TREE_NODE  *Child;\r
-  RED_BLACK_TREE_NODE  *Parent;\r
-  RED_BLACK_TREE_COLOR ColorOfUnlinked;\r
+  RED_BLACK_TREE_NODE   *NewRoot;\r
+  RED_BLACK_TREE_NODE   *OrigLeftChild;\r
+  RED_BLACK_TREE_NODE   *OrigRightChild;\r
+  RED_BLACK_TREE_NODE   *OrigParent;\r
+  RED_BLACK_TREE_NODE   *Child;\r
+  RED_BLACK_TREE_NODE   *Parent;\r
+  RED_BLACK_TREE_COLOR  ColorOfUnlinked;\r
 \r
   NewRoot        = Tree->Root;\r
   OrigLeftChild  = Node->Left,\r
@@ -941,20 +949,21 @@ OrderedCollectionDelete (
   // - Parent will point to the *position* of the original parent of the node\r
   //   that we will have unlinked.\r
   //\r
-  if (OrigLeftChild == NULL || OrigRightChild == NULL) {\r
+  if ((OrigLeftChild == NULL) || (OrigRightChild == NULL)) {\r
     //\r
     // Node has at most one child. We can connect that child (if any) with\r
     // Node's parent (if any), unlinking Node. This will preserve ordering\r
     // because the subtree rooted in Node's child (if any) remains on the same\r
     // side of Node's parent (if any) that Node was before.\r
     //\r
-    Parent = OrigParent;\r
-    Child = (OrigLeftChild != NULL) ? OrigLeftChild : OrigRightChild;\r
+    Parent          = OrigParent;\r
+    Child           = (OrigLeftChild != NULL) ? OrigLeftChild : OrigRightChild;\r
     ColorOfUnlinked = Node->Color;\r
 \r
     if (Child != NULL) {\r
       Child->Parent = Parent;\r
     }\r
+\r
     if (OrigParent == NULL) {\r
       NewRoot = Child;\r
     } else {\r
@@ -978,7 +987,7 @@ OrderedCollectionDelete (
     //   of Node's parent as Node itself. The relinking doesn't change this\r
     //   relation.\r
     //\r
-    RED_BLACK_TREE_NODE *ToRelink;\r
+    RED_BLACK_TREE_NODE  *ToRelink;\r
 \r
     ToRelink = OrigRightChild;\r
     if (ToRelink->Left == NULL) {\r
@@ -994,7 +1003,7 @@ OrderedCollectionDelete (
       //                                            F <--- Child\r
       //\r
       Parent = OrigRightChild;\r
-      Child = OrigRightChild->Right;\r
+      Child  = OrigRightChild->Right;\r
     } else {\r
       do {\r
         ToRelink = ToRelink->Left;\r
@@ -1013,7 +1022,7 @@ OrderedCollectionDelete (
       //                                  \_\r
       //                                   D <--- Child\r
       Parent = ToRelink->Parent;\r
-      Child = ToRelink->Right;\r
+      Child  = ToRelink->Right;\r
 \r
       //\r
       // Unlink Node's successor (ie. ToRelink):\r
@@ -1046,7 +1055,7 @@ OrderedCollectionDelete (
       //\r
       //\r
       //\r
-      ToRelink->Right = OrigRightChild;\r
+      ToRelink->Right        = OrigRightChild;\r
       OrigRightChild->Parent = ToRelink;\r
     }\r
 \r
@@ -1066,7 +1075,7 @@ OrderedCollectionDelete (
     //                    |                                        D <--- Child\r
     //                  Child\r
     //\r
-    ToRelink->Left = OrigLeftChild;\r
+    ToRelink->Left        = OrigLeftChild;\r
     OrigLeftChild->Parent = ToRelink;\r
 \r
     //\r
@@ -1129,9 +1138,9 @@ OrderedCollectionDelete (
     // Rotations in the loop preserve property #4.\r
     //\r
     while (Child != NewRoot && NodeIsNullOrBlack (Child)) {\r
-      RED_BLACK_TREE_NODE *Sibling;\r
-      RED_BLACK_TREE_NODE *LeftNephew;\r
-      RED_BLACK_TREE_NODE *RightNephew;\r
+      RED_BLACK_TREE_NODE  *Sibling;\r
+      RED_BLACK_TREE_NODE  *LeftNephew;\r
+      RED_BLACK_TREE_NODE  *RightNephew;\r
 \r
       if (Child == Parent->Left) {\r
         Sibling = Parent->Right;\r
@@ -1163,7 +1172,7 @@ OrderedCollectionDelete (
           //                        b:C  b:E          Child,2b:A  Sibling,b:C\r
           //\r
           Sibling->Color = RedBlackTreeBlack;\r
-          Parent->Color = RedBlackTreeRed;\r
+          Parent->Color  = RedBlackTreeRed;\r
           RedBlackTreeRotateLeft (Parent, &NewRoot);\r
           Sibling = Parent->Right;\r
           //\r
@@ -1177,10 +1186,11 @@ OrderedCollectionDelete (
         // node.)\r
         //\r
         ASSERT (Sibling->Color == RedBlackTreeBlack);\r
-        LeftNephew = Sibling->Left;\r
+        LeftNephew  = Sibling->Left;\r
         RightNephew = Sibling->Right;\r
         if (NodeIsNullOrBlack (LeftNephew) &&\r
-            NodeIsNullOrBlack (RightNephew)) {\r
+            NodeIsNullOrBlack (RightNephew))\r
+        {\r
           //\r
           // In this case we can "steal" one black value from Child and Sibling\r
           // each, and pass it to Parent. "Stealing" means that Sibling (black\r
@@ -1200,8 +1210,8 @@ OrderedCollectionDelete (
           //             LeftNephew,b:C  RightNephew,b:E              b:C  b:E\r
           //\r
           Sibling->Color = RedBlackTreeRed;\r
-          Child = Parent;\r
-          Parent = Parent->Parent;\r
+          Child          = Parent;\r
+          Parent         = Parent->Parent;\r
           //\r
           // Continue ascending.\r
           //\r
@@ -1230,14 +1240,15 @@ OrderedCollectionDelete (
             //            b:C  b:E                                 b:E  b:G\r
             //\r
             LeftNephew->Color = RedBlackTreeBlack;\r
-            Sibling->Color = RedBlackTreeRed;\r
+            Sibling->Color    = RedBlackTreeRed;\r
             RedBlackTreeRotateRight (Sibling, &NewRoot);\r
-            Sibling = Parent->Right;\r
+            Sibling     = Parent->Right;\r
             RightNephew = Sibling->Right;\r
             //\r
             // These operations ensure that...\r
             //\r
           }\r
+\r
           //\r
           // ... RightNephew is definitely red here, plus Sibling is (still)\r
           // black and non-NULL.\r
@@ -1272,8 +1283,8 @@ OrderedCollectionDelete (
           //                      y:C       RightNephew,r:E     b:A     y:C\r
           //\r
           //\r
-          Sibling->Color = Parent->Color;\r
-          Parent->Color = RedBlackTreeBlack;\r
+          Sibling->Color     = Parent->Color;\r
+          Parent->Color      = RedBlackTreeBlack;\r
           RightNephew->Color = RedBlackTreeBlack;\r
           RedBlackTreeRotateLeft (Parent, &NewRoot);\r
           Child = NewRoot;\r
@@ -1289,7 +1300,7 @@ OrderedCollectionDelete (
         ASSERT (Sibling != NULL);\r
         if (Sibling->Color == RedBlackTreeRed) {\r
           Sibling->Color = RedBlackTreeBlack;\r
-          Parent->Color = RedBlackTreeRed;\r
+          Parent->Color  = RedBlackTreeRed;\r
           RedBlackTreeRotateRight (Parent, &NewRoot);\r
           Sibling = Parent->Left;\r
           ASSERT (Sibling != NULL);\r
@@ -1297,26 +1308,28 @@ OrderedCollectionDelete (
 \r
         ASSERT (Sibling->Color == RedBlackTreeBlack);\r
         RightNephew = Sibling->Right;\r
-        LeftNephew = Sibling->Left;\r
+        LeftNephew  = Sibling->Left;\r
         if (NodeIsNullOrBlack (RightNephew) &&\r
-            NodeIsNullOrBlack (LeftNephew)) {\r
+            NodeIsNullOrBlack (LeftNephew))\r
+        {\r
           Sibling->Color = RedBlackTreeRed;\r
-          Child = Parent;\r
-          Parent = Parent->Parent;\r
+          Child          = Parent;\r
+          Parent         = Parent->Parent;\r
         } else {\r
           if (NodeIsNullOrBlack (LeftNephew)) {\r
             RightNephew->Color = RedBlackTreeBlack;\r
-            Sibling->Color = RedBlackTreeRed;\r
+            Sibling->Color     = RedBlackTreeRed;\r
             RedBlackTreeRotateLeft (Sibling, &NewRoot);\r
-            Sibling = Parent->Left;\r
+            Sibling    = Parent->Left;\r
             LeftNephew = Sibling->Left;\r
           }\r
+\r
           ASSERT (LeftNephew != NULL);\r
           ASSERT (LeftNephew->Color == RedBlackTreeRed);\r
           ASSERT (Sibling != NULL);\r
           ASSERT (Sibling->Color == RedBlackTreeBlack);\r
-          Sibling->Color = Parent->Color;\r
-          Parent->Color = RedBlackTreeBlack;\r
+          Sibling->Color    = Parent->Color;\r
+          Parent->Color     = RedBlackTreeBlack;\r
           LeftNephew->Color = RedBlackTreeBlack;\r
           RedBlackTreeRotateRight (Parent, &NewRoot);\r
           Child = NewRoot;\r
@@ -1336,7 +1349,6 @@ OrderedCollectionDelete (
   }\r
 }\r
 \r
-\r
 /**\r
   Recursively check the red-black tree properties #1 to #4 on a node.\r
 \r
@@ -1346,11 +1358,11 @@ OrderedCollectionDelete (
 **/\r
 UINT32\r
 RedBlackTreeRecursiveCheck (\r
-  IN CONST RED_BLACK_TREE_NODE *Node\r
+  IN CONST RED_BLACK_TREE_NODE  *Node\r
   )\r
 {\r
-  UINT32 LeftHeight;\r
-  UINT32 RightHeight;\r
+  UINT32  LeftHeight;\r
+  UINT32  RightHeight;\r
 \r
   //\r
   // property #2\r
@@ -1375,14 +1387,13 @@ RedBlackTreeRecursiveCheck (
   //\r
   // property #4\r
   //\r
-  LeftHeight = RedBlackTreeRecursiveCheck (Node->Left);\r
+  LeftHeight  = RedBlackTreeRecursiveCheck (Node->Left);\r
   RightHeight = RedBlackTreeRecursiveCheck (Node->Right);\r
   ASSERT (LeftHeight == RightHeight);\r
 \r
   return (Node->Color == RedBlackTreeBlack) + LeftHeight;\r
 }\r
 \r
-\r
 /**\r
   A slow function that asserts that the tree is a valid red-black tree, and\r
   that it orders user structures correctly.\r
@@ -1396,14 +1407,14 @@ RedBlackTreeRecursiveCheck (
 **/\r
 VOID\r
 RedBlackTreeValidate (\r
-  IN CONST RED_BLACK_TREE *Tree\r
+  IN CONST RED_BLACK_TREE  *Tree\r
   )\r
 {\r
-  UINT32                    BlackHeight;\r
-  UINT32                    ForwardCount;\r
-  UINT32                    BackwardCount;\r
-  CONST RED_BLACK_TREE_NODE *Last;\r
-  CONST RED_BLACK_TREE_NODE *Node;\r
+  UINT32                     BlackHeight;\r
+  UINT32                     ForwardCount;\r
+  UINT32                     BackwardCount;\r
+  CONST RED_BLACK_TREE_NODE  *Last;\r
+  CONST RED_BLACK_TREE_NODE  *Node;\r
 \r
   DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p\n", __FUNCTION__, Tree));\r
 \r
@@ -1420,10 +1431,11 @@ RedBlackTreeValidate (
   //\r
   // forward ordering\r
   //\r
-  Last = OrderedCollectionMin (Tree);\r
+  Last         = OrderedCollectionMin (Tree);\r
   ForwardCount = (Last != NULL);\r
   for (Node = OrderedCollectionNext (Last); Node != NULL;\r
-       Node = OrderedCollectionNext (Last)) {\r
+       Node = OrderedCollectionNext (Last))\r
+  {\r
     ASSERT (Tree->UserStructCompare (Last->UserStruct, Node->UserStruct) < 0);\r
     Last = Node;\r
     ++ForwardCount;\r
@@ -1432,10 +1444,11 @@ RedBlackTreeValidate (
   //\r
   // backward ordering\r
   //\r
-  Last = OrderedCollectionMax (Tree);\r
+  Last          = OrderedCollectionMax (Tree);\r
   BackwardCount = (Last != NULL);\r
   for (Node = OrderedCollectionPrev (Last); Node != NULL;\r
-       Node = OrderedCollectionPrev (Last)) {\r
+       Node = OrderedCollectionPrev (Last))\r
+  {\r
     ASSERT (Tree->UserStructCompare (Last->UserStruct, Node->UserStruct) > 0);\r
     Last = Node;\r
     ++BackwardCount;\r
@@ -1443,6 +1456,12 @@ RedBlackTreeValidate (
 \r
   ASSERT (ForwardCount == BackwardCount);\r
 \r
-  DEBUG ((DEBUG_VERBOSE, "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",\r
-    __FUNCTION__, Tree, (INT64)BlackHeight, (INT64)ForwardCount));\r
+  DEBUG ((\r
+    DEBUG_VERBOSE,\r
+    "%a: Tree=%p BlackHeight=%Ld Count=%Ld\n",\r
+    __FUNCTION__,\r
+    Tree,\r
+    (INT64)BlackHeight,\r
+    (INT64)ForwardCount\r
+    ));\r
 }\r