root / mainbox / event.c @ master
History | View | Annotate | Download (602 Bytes)
1 | 75cef49f | Tom Mullins | #include "event.h" |
---|---|---|---|
2 | #include "query.h" |
||
3 | #include <stdlib.h> |
||
4 | |||
5 | struct event_t *head, *tail;
|
||
6 | |||
7 | struct event_t *event_alloc() {
|
||
8 | return malloc(sizeof(struct event_t)); |
||
9 | } |
||
10 | |||
11 | void event_free(struct event_t *event) { |
||
12 | free(event); |
||
13 | } |
||
14 | |||
15 | void event_q_push(struct event_t *event) { |
||
16 | if (tail)
|
||
17 | tail->next = event; |
||
18 | else
|
||
19 | head = event; |
||
20 | tail = event; |
||
21 | 880dc54f | Tom Mullins | event->next = NULL;
|
22 | 75cef49f | Tom Mullins | } |
23 | |||
24 | void event_q_process() {
|
||
25 | struct event_t *old;
|
||
26 | if (head && query_add_event(head) == 0) { |
||
27 | old = head; |
||
28 | 90bb5fa7 | Tom Mullins | if (head == tail) {
|
29 | head = NULL;
|
||
30 | tail = NULL;
|
||
31 | } else
|
||
32 | head = head->next; |
||
33 | 75cef49f | Tom Mullins | event_free(old); |
34 | } |
||
35 | } |