Initializtion

This commit is contained in:
Kozar 2024-04-25 21:36:52 +02:00
parent bcf92ad070
commit 65f1c89f27

View File

@ -25,10 +25,14 @@ node_t *build_tree(int *tree_data, size_t tree_data_len) {
current = current->left; current = current->left;
} else { } else {
current = current->right; current = current->right;
} }
} }
current = malloc(sizeof(node_t)); current = malloc(sizeof(node_t));
if (current == NULL) {
free_tree(root);
return NULL;
}
current->data = tree_data[i]; current->data = tree_data[i];
current->left = NULL; current->left = NULL;
current->right = NULL; current->right = NULL;