Lines Matching refs:root
8 #define smaller(root, a, b) (root->cmp((a)->value, (b)->value) == -1) argument
9 #define equal(root, a, b) (root->cmp((a)->value, (b)->value) == 0) argument
10 #define greater(root, a, b) (root->cmp((a)->value, (b)->value) == 1) argument
25 struct bt_root_t *root = (struct bt_root_t *)kmalloc(sizeof(struct bt_root_t), 0); in bt_create_tree() local
26 memset((void *)root, 0, sizeof(struct bt_root_t)); in bt_create_tree()
27 root->bt_node = node; in bt_create_tree()
28 root->cmp = cmp; in bt_create_tree()
29 root->release = release; in bt_create_tree()
30 root->size = (node == NULL) ? 0 : 1; in bt_create_tree()
32 return root; in bt_create_tree()
65 int bt_insert(struct bt_root_t *root, void *value) in bt_insert() argument
67 if (root == NULL) in bt_insert()
70 struct bt_node_t *this_node = root->bt_node; in bt_insert()
78 if (smaller(root, insert_node, this_node)) in bt_insert()
86 root->bt_node = insert_node; in bt_insert()
89 if (smaller(root, insert_node, last_node)) in bt_insert()
94 ++root->size; in bt_insert()
108 int bt_query(struct bt_root_t *root, void *value, uint64_t *ret_addr) in bt_query() argument
110 struct bt_node_t *this_node = root->bt_node; in bt_query()
118 while (this_node != NULL && !equal(root, this_node, &tmp_node)) in bt_query()
120 if (smaller(root, &tmp_node, this_node)) in bt_query()
126 if (this_node != NULL && equal(root, this_node, &tmp_node)) in bt_query()
153 int bt_delete(struct bt_root_t *root, void *value) in bt_delete() argument
159 retval = bt_query(root, value, &tmp_addr); in bt_delete()
171 root->release(this_node->value); in bt_delete()
184 root->bt_node = to_delete_son; in bt_delete()
193 --root->size; in bt_delete()
204 int bt_destroy_tree(struct bt_root_t *root) in bt_destroy_tree() argument
209 kfifo_alloc(&fifo, ((root->size + 1) / 2) * sizeof(struct bt_node_t *), 0); in bt_destroy_tree()
210 kfifo_in(&fifo, (void *)&(root->bt_node), sizeof(struct bt_node_t *)); in bt_destroy_tree()
227 root->release(nd->value); in bt_destroy_tree()