Hey guys im trying to delete the last node in a doubly linked list so far i have traversed and found the end using a while loop then making PREVIOUS which is now the last one to equal NULL. Then i am freeing the node that i have malloced would this work for a doubly linked list?

Code:
while(current->next !=NULL)
{
   previous = current;
   current = current->next;
}
previous->next = NULL
free(current)