changeset 40:5b1e38a41bac

Cosmetic cleanups.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 02 Oct 2011 23:58:42 +0300
parents 0d55592e0e01
children 8a47eeb4462f
files th_util.c
diffstat 1 files changed, 36 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/th_util.c	Sun Oct 02 23:57:09 2011 +0300
+++ b/th_util.c	Sun Oct 02 23:58:42 2011 +0300
@@ -152,7 +152,6 @@
 }
 #endif
 
-
 /* Doubly linked list handling
  *
  * In this implementation first node's prev points to last node of the list,
@@ -170,7 +169,8 @@
 {
     qlist_t *curr = list;
 
-    while (curr != NULL) {
+    while (curr != NULL)
+    {
         qlist_t *next = curr->next;
         if (freefunc != NULL && curr->data != NULL)
             freefunc(curr->data);
@@ -187,12 +187,15 @@
 
 void th_llist_append_node(qlist_t **list, qlist_t *node)
 {
-    if (*list != NULL) {
+    if (*list != NULL)
+    {
         node->prev = (*list)->prev;
         (*list)->prev->next = node;
         (*list)->prev = node;
         (*list)->num++;
-    } else {
+    }
+    else
+    {
         *list = node;
         node->prev = *list;
         (*list)->num = 1;
@@ -214,13 +217,16 @@
 
 void th_llist_prepend_node(qlist_t **list, qlist_t *node)
 {
-    if (*list != NULL) {
+    if (*list != NULL)
+    {
         node->prev = (*list)->prev;
         node->next = *list;
         (*list)->prev = node;
         node->num = (*list)->num + 1;
         *list = node;
-    } else {
+    }
+    else
+    {
         *list = node->prev = node;
         node->next = NULL;
         (*list)->num = 1;
@@ -273,15 +279,19 @@
 */
 static void th_llist_delete_node_fast(qlist_t **list, qlist_t *node)
 {
-    if (node == *list) {
+    if (node == *list)
+    {
         /* First node in list */
         qlist_t *tmp = (*list)->next;
-        if (tmp != NULL) {
+        if (tmp != NULL)
+        {
             tmp->num = (*list)->num - 1;
             tmp->prev = (*list)->prev;
         }
         *list = tmp;
-    } else {
+    }
+    else
+    {
         /* Somewhere in middle or end */
         if (node->prev != NULL)
             node->prev->next = node->next;
@@ -302,9 +312,11 @@
 {
     qlist_t *curr = *list;
 
-    while (curr != NULL) {
+    while (curr != NULL)
+    {
         qlist_t *next = curr->next;
-        if (curr == node) {
+        if (curr == node)
+        {
             th_llist_delete_node_fast(list, curr);
             th_free(node);
             break;
@@ -318,9 +330,11 @@
 {
     qlist_t *curr = *list;
 
-    while (curr != NULL) {
+    while (curr != NULL)
+    {
         qlist_t *next = curr->next;
-        if (curr->data == data) {
+        if (curr->data == data)
+        {
             th_llist_delete_node_fast(list, curr);
             th_free(curr);
             break;
@@ -355,7 +369,8 @@
     const qlist_t *curr = list;
     ssize_t i = 0;
 
-    while (curr != NULL) {
+    while (curr != NULL)
+    {
         if (curr == node)
             return i;
         else
@@ -372,7 +387,8 @@
 {
     qlist_t *curr = list;
 
-    while (curr != NULL) {
+    while (curr != NULL)
+    {
         if (curr->data == data)
             return curr;
         curr = curr->next;
@@ -386,7 +402,8 @@
 {
     qlist_t *curr = list;
 
-    while (curr != NULL) {
+    while (curr != NULL)
+    {
         if (compare(curr->data, userdata) == 0)
             return curr;
         curr = curr->next;
@@ -415,8 +432,9 @@
 BOOL th_ringbuf_grow(qringbuf_t *buf, const size_t n)
 {
     buf->data = (char **) th_realloc(buf->data, (buf->size + n) * sizeof(char *));
-    if (buf->data != NULL) {
-        memset(buf->data + buf->size, 0, sizeof(char *) * n);
+    if (buf->data != NULL)
+    {
+        th_memset(buf->data + buf->size, 0, sizeof(char *) * n);
         buf->size += n;
         return TRUE;
     } else