Project

General

Profile

Statistics
| Branch: | Revision:

root / mainbox / event.c @ 90bb5fa7

History | View | Annotate | Download (602 Bytes)

1
#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
  event->next = NULL;
22
}
23

    
24
void event_q_process() {
25
  struct event_t *old;
26
  if (head && query_add_event(head) == 0) {
27
    old = head;
28
    if (head == tail) {
29
      head = NULL;
30
      tail = NULL;
31
    } else
32
      head = head->next;
33
    event_free(old);
34
  }
35
}