Skip to content

Instantly share code, notes, and snippets.

@devansh42
Last active July 29, 2019 19:52
Show Gist options
  • Save devansh42/79b5005d286567645d46db94cc3db746 to your computer and use it in GitHub Desktop.
Save devansh42/79b5005d286567645d46db94cc3db746 to your computer and use it in GitHub Desktop.
void delete_list(LinkedList* list){
Node* i;
/**
* Deallocating memory associated with each node
* Starting from head node
* Ends whenever we reach at the end
* We go to next node in each iteration
*/
for(i=list->head;i;i=i->next){ //Traversing Linked List
free(i); //Deallocatind memory of i'th node
}
free(list); //Freeing memory for LinkedList object
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment