Mercurial > hg > th-libs
comparison th_config.c @ 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 | b4e1b15a64e1 |
children | fc914ff7a9b8 |
comparison
equal
deleted
inserted
replaced
154:a6f175e301cc | 155:23a79bd6c9d6 |
---|---|
20 { | 20 { |
21 th_cfgitem_t *node = cfg; | 21 th_cfgitem_t *node = cfg; |
22 | 22 |
23 while (node != NULL) | 23 while (node != NULL) |
24 { | 24 { |
25 th_cfgitem_t *next = node->next; | 25 th_cfgitem_t *next = (th_cfgitem_t *) node->node.next; |
26 | 26 |
27 if (node->type == ITEM_SECTION) | 27 if (node->type == ITEM_SECTION) |
28 th_cfg_free((th_cfgitem_t *) node->v.data); | 28 th_cfg_free((th_cfgitem_t *) node->v.data); |
29 | 29 |
30 th_free(node->name); | 30 th_free(node->name); |
53 node->type = type; | 53 node->type = type; |
54 node->v.data = data; | 54 node->v.data = data; |
55 node->name = th_strdup(name); | 55 node->name = th_strdup(name); |
56 | 56 |
57 // Insert into linked list | 57 // Insert into linked list |
58 if (*cfg != NULL) | 58 th_llist_append_node((th_llist_t **) cfg, (th_llist_t *) node); |
59 { | |
60 node->prev = (*cfg)->prev; | |
61 (*cfg)->prev->next = node; | |
62 (*cfg)->prev = node; | |
63 } | |
64 else | |
65 { | |
66 *cfg = node; | |
67 node->prev = node; | |
68 } | |
69 node->next = NULL; | |
70 | 59 |
71 return node; | 60 return node; |
72 } | 61 } |
73 | 62 |
74 | 63 |
360 while (item != NULL && !isFound) | 349 while (item != NULL && !isFound) |
361 { | 350 { |
362 if (item->name != NULL && strcmp(item->name, tmpStr) == 0) | 351 if (item->name != NULL && strcmp(item->name, tmpStr) == 0) |
363 isFound = TRUE; | 352 isFound = TRUE; |
364 else | 353 else |
365 item = item->next; | 354 item = (th_cfgitem_t *) item->node.next; |
366 } | 355 } |
367 | 356 |
368 // Check if key was found | 357 // Check if key was found |
369 if (isFound) | 358 if (isFound) |
370 { | 359 { |
800 item->name, *(item->v.val_int)) < 0) | 789 item->name, *(item->v.val_int)) < 0) |
801 return -6; | 790 return -6; |
802 break; | 791 break; |
803 } | 792 } |
804 } | 793 } |
805 item = item->next; | 794 item = (th_cfgitem_t *) item->node.next; |
806 } | 795 } |
807 | 796 |
808 return 0; | 797 return 0; |
809 } | 798 } |
810 | 799 |