changeset 155:23a79bd6c9d6

Use th_llist for th_config module as well instead of duped linked list implementation.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 07 Feb 2015 00:33:41 +0200
parents a6f175e301cc
children 79e904905dbf
files th_config.c th_config.h
diffstat 2 files changed, 7 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/th_config.c	Sat Feb 07 00:33:16 2015 +0200
+++ b/th_config.c	Sat Feb 07 00:33:41 2015 +0200
@@ -22,7 +22,7 @@
 
     while (node != NULL)
     {
-        th_cfgitem_t *next = node->next;
+        th_cfgitem_t *next = (th_cfgitem_t *) node->node.next;
 
         if (node->type == ITEM_SECTION)
             th_cfg_free((th_cfgitem_t *) node->v.data);
@@ -55,18 +55,7 @@
     node->name = th_strdup(name);
 
     // Insert into linked list
-    if (*cfg != NULL)
-    {
-        node->prev = (*cfg)->prev;
-        (*cfg)->prev->next = node;
-        (*cfg)->prev = node;
-    }
-    else
-    {
-        *cfg = node;
-        node->prev = node;
-    }
-    node->next = NULL;
+    th_llist_append_node((th_llist_t **) cfg, (th_llist_t *) node);
 
     return node;
 }
@@ -362,7 +351,7 @@
                     if (item->name != NULL && strcmp(item->name, tmpStr) == 0)
                         isFound = TRUE;
                     else
-                        item = item->next;
+                        item = (th_cfgitem_t *) item->node.next;
                 }
 
                 // Check if key was found
@@ -802,7 +791,7 @@
                 break;
             }
         }
-        item = item->next;
+        item = (th_cfgitem_t *) item->node.next;
     }
 
     return 0;
--- a/th_config.h	Sat Feb 07 00:33:16 2015 +0200
+++ b/th_config.h	Sat Feb 07 00:33:41 2015 +0200
@@ -8,6 +8,7 @@
 #ifndef TH_CONFIG_H
 #define TH_CONFIG_H
 
+#include "th_util.h"
 #include "th_ioctx.h"
 
 #ifdef __cplusplus
@@ -34,6 +35,8 @@
 
 typedef struct _th_cfgitem_t
 {
+    th_llist_t node;
+
     int  type;
     char *name;
     union {
@@ -46,8 +49,6 @@
         th_llist_t **list;
         struct _th_cfgitem_t *section;
     } v;
-    
-    struct _th_cfgitem_t *next, *prev;
 } th_cfgitem_t;