/*
splay_tree.c -- splay tree and linked list convenience
- Copyright (C) 2014 Guus Sliepen <guus@meshlink.io>
+ Copyright (C) 2014-2017 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
/* Splay operation */
static splay_node_t *splay_top_down(splay_tree_t *tree, const void *data, int *result) {
- splay_node_t left = {NULL}, right = {NULL};
+ splay_node_t left = {}, right = {};
splay_node_t *leftbottom = &left, *rightbottom = &right, *child, *grandchild;
splay_node_t *root = tree->root;
int c;
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;
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;
root = child;
break;
}
- } else {
+ } else
break;
- }
}
/* Merge trees */
node = node->right;
else
break;
- } else {
+ } else
break;
- }
}
if(result)
} else if(node->next) {
tree->root = node->right;
node->right->parent = NULL;
- } else {
+ } else
tree->root = NULL;
- }
tree->count--;
}