This function is supposed to delete linked list in C only if it is empty. The ll_length() function is confirmed working. If the linked list is successfully deleted, we are to return 0. If it is not deleted, return negative one. This program is returning -1. It enters the first if statement but not the second. What is wrong
ll_destroy(struct linked_list *ll)
{
if (ll_length(ll) == 0){
free(ll);
if (ll == NULL){
return 0; //remove 0 if removed
}
}
return -1; // if not deleted
}
Aucun commentaire:
Enregistrer un commentaire