# HG changeset patch # User Matti Hamalainen # Date 1423262021 -7200 # Node ID 23a79bd6c9d6c77592fefe85d6e4d175aa6a767f # Parent a6f175e301ccec2e9464bbe91de547cbd7829c6a Use th_llist for th_config module as well instead of duped linked list implementation. diff -r a6f175e301cc -r 23a79bd6c9d6 th_config.c --- 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; diff -r a6f175e301cc -r 23a79bd6c9d6 th_config.h --- 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;