forked from lda/telodendria
Fix logic error relating to the initial call to QueuePush()
This commit is contained in:
parent
665da9d33e
commit
55a49e418f
1 changed files with 9 additions and 1 deletions
10
src/Queue.c
10
src/Queue.c
|
@ -115,7 +115,15 @@ QueuePush(Queue * q, void *element)
|
|||
q->front = 0;
|
||||
}
|
||||
|
||||
q->rear = (q->rear + 1) % q->size;
|
||||
if (q->rear == q->size + 1)
|
||||
{
|
||||
q->rear = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
q->rear = (q->rear + 1) % q->size;
|
||||
}
|
||||
|
||||
q->items[q->rear] = element;
|
||||
|
||||
return 1;
|
||||
|
|
Loading…
Reference in a new issue