2 * Copyright (C) 2009 Neverball authors
4 * NEVERBALL is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
30 if ((new = malloc(sizeof (*new))))
31 new->head = new->tail = list_cons(NULL, NULL);
36 void queue_free(Queue q)
38 assert(queue_empty(q));
43 int queue_empty(Queue q)
46 return q->head == q->tail;
49 void queue_enq(Queue q, void *data)
54 q->tail->next = list_cons(NULL, NULL);
56 q->tail = q->tail->next;
59 void *queue_deq(Queue q)
66 q->head = list_rest(q->head);