Event *EventListRemove( Event *e ) { Condition *c = e->conditions; Action *a = e->actions; Event *next = e->next; // Remove event from the EventList e->next->prev = e->prev; e->prev->next = e->next; // Free all conditions of this event while(c) { Condition *temp = c; if(c->clean) c->clean( c ); // Run condition's cleanup c = c->next; free( temp ); } // Free all actions of this event while(a) { Action *temp = a; if(a->clean) a->clean( a ); // Run action's cleanup a = a->next; free( temp ); } // Free the event free( e ); return next; }