diff --git a/queue.c b/queue.c index b20a6ad91b9407b4552ab5f210e22e2a9e492ff6..520aabfbcdaf29ce4d2286c0b7d40cfd43dcdb26 100644 --- a/queue.c +++ b/queue.c @@ -37,7 +37,14 @@ Queue* delete(Queue* q) { } Node* ptr = q->front; + if(q->front == q->rear) { + free(q->front); + q->front=q->rear=NULL; + return q; + } + q->front = q->front->next; + free(ptr); return q; }