]> git.meshlink.io Git - meshlink/blobdiff - src/splay_tree.c
Add a test for a constellation of three nodes.
[meshlink] / src / splay_tree.c
index aed91561d577ba734e902d88e2141daf73410924..d84948ed64aaa9f0ae7e27963ca200b509d9c320 100644 (file)
@@ -1,6 +1,6 @@
 /*
     splay_tree.c -- splay tree and linked list convenience
-    Copyright (C) 2004-2013 Guus Sliepen <guus@meshlink.io>
+    Copyright (C) 2014 Guus Sliepen <guus@meshlink.io>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -55,7 +55,7 @@ static splay_node_t *splay_top_down(splay_tree_t *tree, const void *data, int *r
                                grandchild->parent = NULL;
 
                                root = grandchild;
-                       } else if (c > 0 && (grandchild = child->right)) {
+                       } else if(c > 0 && (grandchild = child->right)) {
                                leftbottom->right = child;
                                child->parent = leftbottom;
                                leftbottom = child;
@@ -99,7 +99,7 @@ static splay_node_t *splay_top_down(splay_tree_t *tree, const void *data, int *r
                                grandchild->parent = NULL;
 
                                root = grandchild;
-                       } else if (c < 0 && (grandchild = child->left)) {
+                       } else if(c < 0 && (grandchild = child->left)) {
                                rightbottom->left = child;
                                child->parent = rightbottom;
                                rightbottom = child;
@@ -125,9 +125,8 @@ static splay_node_t *splay_top_down(splay_tree_t *tree, const void *data, int *r
                                root = child;
                                break;
                        }
-               } else {
+               } else
                        break;
-               }
        }
 
        /* Merge trees */
@@ -328,9 +327,8 @@ splay_node_t *splay_search_closest_node_nosplay(const splay_tree_t *tree, const
                                node = node->right;
                        else
                                break;
-               } else {
+               } else
                        break;
-               }
        }
 
        if(result)
@@ -513,9 +511,8 @@ void splay_unlink_node(splay_tree_t *tree, splay_node_t *node) {
        } else if(node->next) {
                tree->root = node->right;
                node->right->parent = NULL;
-       } else {
+       } else
                tree->root = NULL;
-       }
 
        tree->count--;
 }