-void event_del(event_t *event)
-{
-cp
- avl_delete(event_tree, event);
-cp
+void event_add(event_t *event) {
+ event->id = ++id;
+ avl_insert(event_tree, event);
+}
+
+void event_del(event_t *event) {
+ avl_delete(event_tree, event);
+}
+
+event_t *get_expired_event(void) {
+ event_t *event;
+
+ if(event_tree->head) {
+ event = event_tree->head->data;
+
+ if(event->time <= now) {
+ avl_node_t *node = event_tree->head;
+ avl_unlink_node(event_tree, node);
+ free(node);
+ return event;
+ }
+ }
+
+ return NULL;