A pointer to the root of the B-tree and a number to be inserted into the tree are passed to the function:
void bt_insert(Tree** tree_ptr, const int key); further, it looks for a node into which data can be inserted:
if (!(*tree_ptr)->is_leaf) node = bt_get_node(*tree_ptr, key); else node = *tree_ptr; after inserting data into a tree, it is balanced if necessary
if (node->count != DEGREE) return; bt_balance(&node); But in case you need to balance the root element, tree_ptr and node have different values. That is, if
else node = *tree_ptr; That tree_ptr != &node
And I cannot insert another node instead of *tree_ptr in the bt_balance function (according to the algorithm).
What can be done here?