+void expire_events(void) {
+ avl_node_t *node;
+ event_t *event;
+ time_t diff;
+
+ /*
+ * Make all events appear expired by subtracting the difference between
+ * the expiration time of the last event and the current time.
+ */
+
+ if(!event_tree->tail) {
+ return;
+ }
+
+ event = event_tree->tail->data;
+
+ if(event->time <= now) {
+ return;
+ }
+
+ diff = event->time - now;
+
+ for(node = event_tree->head; node; node = node->next) {
+ event = node->data;
+ event->time -= diff;
+ }
+}
+
+event_t *new_event(void) {
+ return xmalloc_and_zero(sizeof(event_t));
+}
+
+void free_event(event_t *event) {
+ free(event);