X-Git-Url: https://tinc-vpn.org/git/browse?p=tinc;a=blobdiff_plain;f=src%2Fevent.c;h=99e6a2381280c95d5365fce5020e8a450662d4f0;hp=bd9bfa288c0f37adbac02dbc028c235c27745cd8;hb=5d194b9f8767390d9fb1170554a8b6928214957a;hpb=c217d214f4f071c235bc7c463a1da6124e2570a6 diff --git a/src/event.c b/src/event.c index bd9bfa28..99e6a238 100644 --- a/src/event.c +++ b/src/event.c @@ -13,9 +13,9 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #include "system.h" @@ -30,8 +30,7 @@ extern time_t now; int id; -static int event_compare(const event_t *a, const event_t *b) -{ +static int event_compare(const event_t *a, const event_t *b) { if(a->time > b->time) return 1; @@ -41,22 +40,15 @@ static int event_compare(const event_t *a, const event_t *b) return a->id - b->id; } -void init_events(void) -{ - cp(); - +void init_events(void) { event_tree = avl_alloc_tree((avl_compare_t) event_compare, (avl_action_t) free_event); } -void exit_events(void) -{ - cp(); - +void exit_events(void) { avl_delete_tree(event_tree); } -void expire_events(void) -{ +void expire_events(void) { avl_node_t *node; event_t *event; time_t diff; @@ -66,8 +58,6 @@ void expire_events(void) * the expiration time of the last event and the current time. */ - cp(); - if(!event_tree->tail) return; @@ -83,41 +73,26 @@ void expire_events(void) } } -event_t *new_event(void) -{ - cp(); - +event_t *new_event(void) { return xmalloc_and_zero(sizeof(event_t)); } -void free_event(event_t *event) -{ - cp(); - +void free_event(event_t *event) { free(event); } -void event_add(event_t *event) -{ - cp(); - +void event_add(event_t *event) { event->id = ++id; avl_insert(event_tree, event); } -void event_del(event_t *event) -{ - cp(); - +void event_del(event_t *event) { avl_delete(event_tree, event); } -event_t *get_expired_event(void) -{ +event_t *get_expired_event(void) { event_t *event; - cp(); - if(event_tree->head) { event = event_tree->head->data;