kernel: port sandbox components
This commit is contained in:
23
ds/btree.c
23
ds/btree.c
@@ -59,9 +59,6 @@
|
||||
|
||||
#include <socks/btree.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <assert.h>
|
||||
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
@@ -130,15 +127,7 @@ static inline int bf(btree_node_t *x)
|
||||
*/
|
||||
static void rotate_left(btree_t *tree, btree_node_t *x)
|
||||
{
|
||||
assert(x != NULL);
|
||||
|
||||
btree_node_t *y = x->b_right;
|
||||
assert(y != NULL);
|
||||
|
||||
assert(y == x->b_left || y == x->b_right);
|
||||
if (x->b_parent) {
|
||||
assert(x == x->b_parent->b_left || x == x->b_parent->b_right);
|
||||
}
|
||||
|
||||
btree_node_t *p = x->b_parent;
|
||||
|
||||
@@ -197,15 +186,7 @@ static void update_height_to_root(btree_node_t *x)
|
||||
*/
|
||||
static void rotate_right(btree_t *tree, btree_node_t *y)
|
||||
{
|
||||
assert(y);
|
||||
|
||||
btree_node_t *x = y->b_left;
|
||||
assert(x);
|
||||
|
||||
assert(x == y->b_left || x == y->b_right);
|
||||
if (y->b_parent) {
|
||||
assert(y == y->b_parent->b_left || y == y->b_parent->b_right);
|
||||
}
|
||||
|
||||
btree_node_t *p = y->b_parent;
|
||||
|
||||
@@ -338,10 +319,6 @@ static void insert_fixup(btree_t *tree, btree_node_t *w)
|
||||
goto next_ancestor;
|
||||
}
|
||||
|
||||
assert(x && y && z);
|
||||
assert(x == y->b_left || x == y->b_right);
|
||||
assert(y == z->b_left || y == z->b_right);
|
||||
|
||||
if (IS_LEFT_CHILD(z, y)) {
|
||||
if (IS_LEFT_CHILD(y, x)) {
|
||||
rotate_right(tree, z);
|
||||
|
||||
Reference in New Issue
Block a user