之前卡死是因为对空指针访问了成员

This commit is contained in:
建峰 2024-06-23 16:16:56 +08:00
parent 2f3f1bdf37
commit 3589b1e069

View File

@ -1458,8 +1458,6 @@ static bool tree_node_free(struct _tree_node* node)
*/ */
struct _tree_node * tree_find_pos(struct _tree* self, void* obj) struct _tree_node * tree_find_pos(struct _tree* self, void* obj)
{ {
printf("222\n");
assert(self != NULL); assert(self != NULL);
assert(self->compare != NULL); assert(self->compare != NULL);
@ -1511,10 +1509,7 @@ bool tree_avl_insert(struct _tree* self, void* obj)
else else
{ {
// insert the node // insert the node
struct _tree_node* root = NULL; struct _tree_node* root = tree_find_pos(self, obj);
printf("111\n");
root = tree_find_pos(self, root->obj);
printf("444\n");
if(self->compare(obj, root->obj) < 0) if(self->compare(obj, root->obj) < 0)
{ {
root->left = node; root->left = node;