Queue/Definition: Difference between revisions
Content deleted Content added
Nimrod -> Nim |
|||
Line 715: | Line 715: | ||
if (q->tail >= q->alloc) q->tail = 0; |
if (q->tail >= q->alloc) q->tail = 0; |
||
q->buf[q->tail++] = n; |
q->buf[q->tail++] = n; |
||
// Previous code was (q->tail == q->) array fails to resize when you use test |
|||
// cases other than the provided one, this fixes it |
|||
if (q->tail == q->alloc) { /* needs more room */ |
|||
q->buf = realloc(q->buf, sizeof(DATA) * q->alloc * 2); |
q->buf = realloc(q->buf, sizeof(DATA) * q->alloc * 2); |
||
if (q->head) { |
if (q->head) { |