K&R style braces
[tinc] / src / node.c
index 2add29d..9d4d2f4 100644 (file)
@@ -1,7 +1,7 @@
 /*
     node.c -- node tree management
-    Copyright (C) 2001-2005 Guus Sliepen <guus@tinc-vpn.org>,
-                  2001-2005 Ivo Timmermans <ivo@tinc-vpn.org>
+    Copyright (C) 2001-2006 Guus Sliepen <guus@tinc-vpn.org>,
+                  2001-2005 Ivo Timmermans
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -35,13 +35,11 @@ avl_tree_t *node_udp_tree;          /* Known nodes, sorted by address and port */
 
 node_t *myself;
 
-static int node_compare(const node_t *a, const node_t *b)
-{
+static int node_compare(const node_t *a, const node_t *b) {
        return strcmp(a->name, b->name);
 }
 
-static int node_udp_compare(const node_t *a, const node_t *b)
-{
+static int node_udp_compare(const node_t *a, const node_t *b) {
        int result;
 
        cp();
@@ -54,24 +52,21 @@ static int node_udp_compare(const node_t *a, const node_t *b)
        return (a->name && b->name) ? strcmp(a->name, b->name) : 0;
 }
 
-void init_nodes(void)
-{
+void init_nodes(void) {
        cp();
 
        node_tree = avl_alloc_tree((avl_compare_t) node_compare, (avl_action_t) free_node);
        node_udp_tree = avl_alloc_tree((avl_compare_t) node_udp_compare, NULL);
 }
 
-void exit_nodes(void)
-{
+void exit_nodes(void) {
        cp();
 
        avl_delete_tree(node_udp_tree);
        avl_delete_tree(node_tree);
 }
 
-node_t *new_node(void)
-{
+node_t *new_node(void) {
        node_t *n = xmalloc_and_zero(sizeof(*n));
 
        cp();
@@ -86,19 +81,12 @@ node_t *new_node(void)
        return n;
 }
 
-void free_node(node_t *n)
-{
+void free_node(node_t *n) {
        cp();
 
        if(n->queue)
                list_delete_list(n->queue);
 
-       if(n->name)
-               free(n->name);
-
-       if(n->hostname)
-               free(n->hostname);
-
        if(n->key)
                free(n->key);
 
@@ -112,21 +100,24 @@ void free_node(node_t *n)
 
        EVP_CIPHER_CTX_cleanup(&n->packet_ctx);
 
-       if(n->mtuevent)
-               event_del(n->mtuevent);
+       event_del(&n->mtuevent);
        
+       if(n->hostname)
+               free(n->hostname);
+
+       if(n->name)
+               free(n->name);
+
        free(n);
 }
 
-void node_add(node_t *n)
-{
+void node_add(node_t *n) {
        cp();
 
        avl_insert(node_tree, n);
 }
 
-void node_del(node_t *n)
-{
+void node_del(node_t *n) {
        avl_node_t *node, *next;
        edge_t *e;
        subnet_t *s;
@@ -148,8 +139,7 @@ void node_del(node_t *n)
        avl_delete(node_tree, n);
 }
 
-node_t *lookup_node(char *name)
-{
+node_t *lookup_node(char *name) {
        node_t n = {0};
 
        cp();
@@ -159,8 +149,7 @@ node_t *lookup_node(char *name)
        return avl_search(node_tree, &n);
 }
 
-node_t *lookup_node_udp(const sockaddr_t *sa)
-{
+node_t *lookup_node_udp(const sockaddr_t *sa) {
        node_t n = {0};
 
        cp();
@@ -171,8 +160,7 @@ node_t *lookup_node_udp(const sockaddr_t *sa)
        return avl_search(node_udp_tree, &n);
 }
 
-void dump_nodes(void)
-{
+void dump_nodes(void) {
        avl_node_t *node;
        node_t *n;