Commit 996cb357 authored by Shivaji's avatar Shivaji

change in remove_queue method

parent 0691e504
...@@ -25,16 +25,23 @@ void remove_element_from_deque(char *key) ...@@ -25,16 +25,23 @@ void remove_element_from_deque(char *key)
queue *present = qu , *previous=NULL; queue *present = qu , *previous=NULL;
if(present == NULL) if(present == NULL)
return; return;
if(strcmp(present->key, key) == 0)
{
qu = qu->next;
if(last == present)
last = last->next;
free(present);
return;
}
while(present->next != NULL) while(present->next != NULL)
{ {
if(present->key == key) if(strcmp(present->key, key) == 0)
{ {
if(previous == NULL)
qu = qu->next;
if(last == present) if(last == present)
last = previous; last = previous;
if(previous) previous->next = present->next;
previous->next = present->next;
free(present); free(present);
return; return;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment