"head" is not even declared, so I doubt that it would compile.
I believe that you want to free head, not next.


On Apr 9, 11:31 am, rahul sharma <rahul23111...@gmail.com> wrote:
>  Is the following code correct for linked list deletion or i need to copy
> head in some tem. pointer and dlete and theninitialize head to NULLL.Plz
> comment
>  void deleteList(struct node** head_ref)
>  {
>     /* deref head_ref to get the real head */
>       struct node* next;
>
>    while (*head != NULL)
>     {
>         next = *head->next;
>         free(next);
>         *head = next;
>     }
>
>  }

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to