- list.c: removed pointless 0 assignments in node_create() and list_create()
authormichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>
Mon, 16 Mar 2015 16:43:00 +0000 (16:43 +0000)
committermichael <michael@82007160-df01-0410-b94d-b575c5fd34c7>
Mon, 16 Mar 2015 16:43:00 +0000 (16:43 +0000)
- list.c, list.h: style corrections

git-svn-id: svn://svn.ircd-hybrid.org/svnroot/hopm/branches/1.0.x@5705 82007160-df01-0410-b94d-b575c5fd34c7

src/list.c
src/list.h

index 3573758e45a424acaad4902fcd4d946caf00a661..0a87195b15db6a0bbb7b6cb6c50374fa0004c933 100644 (file)
 #include "list.h"
 
 
-node_t *node_create(void *data)
+node_t *
+node_create(void *data)
 {
-   node_t *node = xcalloc(sizeof *node);
-   node->next = NULL;
-   node->prev = NULL;
-   node->data = (void *) data;
+  node_t *node = xcalloc(sizeof *node);
 
-   return node;
+  node->data = data;
+
+  return node;
 }
 
-list_t *list_create()
+list_t *
+list_create(void)
 {
-   list_t *list = xcalloc(sizeof *list);
-
-   list->head = NULL;
-   list->tail = NULL;
-
-   list->elements = 0;
-
-   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);
 }
index 2b7668ab7f7381bc0ff012fd39bfdea98273091c..576690f240f9b27a62d61f783a8329c2cc7e92d6 100644 (file)
@@ -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 */