From: michael Date: Mon, 16 Mar 2015 16:40:47 +0000 (+0000) Subject: - list.c, list.h: style corrections X-Git-Tag: 1.1.0beta1~122 X-Git-Url: http://git.serene-ircd.net/?a=commitdiff_plain;h=ceb27fd59ccfd19ce1f5c3737e75583d0d869e69;p=hopm.git - list.c, list.h: style corrections git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/trunk@5704 82007160-df01-0410-b94d-b575c5fd34c7 --- diff --git a/src/list.c b/src/list.c index 61f69aa..0a87195 100644 --- a/src/list.c +++ b/src/list.c @@ -24,82 +24,87 @@ #include "list.h" -node_t *node_create(void *data) +node_t * +node_create(void *data) { - node_t *node = xcalloc(sizeof *node); + node_t *node = xcalloc(sizeof *node); - node->data = data; + node->data = data; - return node; + return node; } -list_t *list_create() +list_t * +list_create(void) { - list_t *list = xcalloc(sizeof *list); - return list; + list_t *list = xcalloc(sizeof *list); + return list; } -node_t *list_add(list_t *list, node_t *node) +node_t * +list_add(list_t *list, node_t *node) { - - if(list == NULL || node == NULL) - return NULL; - - if(list->tail == NULL) - { - list->head = node; - list->tail = node; - - node->next = NULL; - node->prev = NULL; - } - else - { - node->prev = list->tail; - list->tail->next = node; - list->tail = node; - node->next = NULL; - } - - list->elements++; - return node; + if (list == NULL || node == NULL) + return NULL; + + if (list->tail == NULL) + { + list->head = node; + list->tail = node; + + node->next = NULL; + node->prev = NULL; + } + else + { + node->prev = list->tail; + list->tail->next = node; + list->tail = node; + node->next = NULL; + } + + ++list->elements; + return node; } -node_t *list_remove(list_t *list, node_t *node) +node_t * +list_remove(list_t *list, node_t *node) { - if(list == NULL || node == NULL) - return NULL; - - if(node == list->head) - { - list->head = node->next; - - if(node->next) - node->next->prev = NULL; - else - list->tail = NULL; - } - else if(node == list->tail) - { - list->tail = list->tail->prev; - list->tail->next = NULL; - } - else - { - node->prev->next = node->next; - node->next->prev = node->prev; - } - - list->elements--; - return node; + if (list == NULL || node == NULL) + return NULL; + + if (node == list->head) + { + list->head = node->next; + + if (node->next) + node->next->prev = NULL; + else + list->tail = NULL; + } + else if (node == list->tail) + { + list->tail = list->tail->prev; + list->tail->next = NULL; + } + else + { + node->prev->next = node->next; + node->next->prev = node->prev; + } + + --list->elements; + return node; } -void list_free(list_t *list) +void +list_free(list_t *list) { - xfree(list); + xfree(list); } -void node_free(node_t *node) +void +node_free(node_t *node) { xfree(node); } diff --git a/src/list.h b/src/list.h index 2b7668a..576690f 100644 --- a/src/list.h +++ b/src/list.h @@ -31,31 +31,24 @@ typedef struct _list list_t; struct _list { - - struct _node *head; - struct _node *tail; - - int elements; + struct _node *head; + struct _node *tail; + int elements; }; struct _node { - - struct _node *next; - struct _node *prev; - - void *data; + struct _node *next; + struct _node *prev; + void *data; }; +extern node_t *node_create(void *); +extern list_t *list_create(void); +extern node_t *list_add(list_t *, node_t *); +extern node_t *list_remove(list_t *, node_t *); -node_t *node_create(void *); -list_t *list_create(void); - -node_t *list_add(list_t *, node_t *); -node_t *list_remove(list_t *, node_t *); - -void list_free(list_t *); -void node_free(node_t *); - +extern void list_free(list_t *); +extern void node_free(node_t *); #endif /* LIST_H */