# HG changeset patch # User Matti Hamalainen # Date 1423256648 -7200 # Node ID b4e1b15a64e14e1368e7087653281f359d6dfd2e # Parent 434c0eae87c9d6e4bda6cf50c8dd157c868ca781 Rename qlist_t doubly linked list structure to th_llist_t. diff -r 434c0eae87c9 -r b4e1b15a64e1 th_config.c --- a/th_config.c Wed Jan 28 08:06:02 2015 +0200 +++ b/th_config.c Fri Feb 06 23:04:08 2015 +0200 @@ -182,7 +182,7 @@ } -int th_cfg_add_string_list(th_cfgitem_t **cfg, const char *name, qlist_t **data) +int th_cfg_add_string_list(th_cfgitem_t **cfg, const char *name, th_llist_t **data) { th_cfgitem_t *node; @@ -741,7 +741,7 @@ } else { - qlist_t *node = *(item->v.list); + th_llist_t *node = *(item->v.list); size_t n = th_llist_length(node); if (fprintf(ctx->fp, "%s = ", item->name) < 0) return -3; diff -r 434c0eae87c9 -r b4e1b15a64e1 th_config.h --- a/th_config.h Wed Jan 28 08:06:02 2015 +0200 +++ b/th_config.h Fri Feb 06 23:04:08 2015 +0200 @@ -44,7 +44,7 @@ BOOL *val_bool; void *data; - qlist_t **list; + th_llist_t **list; struct _th_cfgitem_t *section; } v; @@ -67,7 +67,7 @@ int th_cfg_add_bool(th_cfgitem_t **cfg, const char *name, BOOL *data, BOOL itemDef); int th_cfg_add_float(th_cfgitem_t **cfg, const char *name, float *data, float itemDef); int th_cfg_add_hexvalue(th_cfgitem_t **cfg, const char *name, int *data, int itemDef); -int th_cfg_add_string_list(th_cfgitem_t **cfg, const char *name, qlist_t **list); +int th_cfg_add_string_list(th_cfgitem_t **cfg, const char *name, th_llist_t **list); th_cfgitem_t *th_cfg_find(th_cfgitem_t *cfg, const char *section, const char *name, const int type); diff -r 434c0eae87c9 -r b4e1b15a64e1 th_network.c --- a/th_network.c Wed Jan 28 08:06:02 2015 +0200 +++ b/th_network.c Fri Feb 06 23:04:08 2015 +0200 @@ -11,7 +11,7 @@ static BOOL th_network_inited = FALSE; -static qlist_t *th_conn_list = NULL; +static th_llist_t *th_conn_list = NULL; enum @@ -864,10 +864,10 @@ if (th_network_inited) { // Close connections - qlist_t *curr = th_conn_list; + th_llist_t *curr = th_conn_list; while (curr != NULL) { - qlist_t *next = curr->next; + th_llist_t *next = curr->next; th_conn_free_nodelete(curr->data); curr = next; } diff -r 434c0eae87c9 -r b4e1b15a64e1 th_util.c --- a/th_util.c Wed Jan 28 08:06:02 2015 +0200 +++ b/th_util.c Fri Feb 06 23:04:08 2015 +0200 @@ -232,20 +232,20 @@ * and last node's next is NULL. This way we can semi-efficiently traverse to * beginning and end of the list, assuming user does not do weird things. */ -qlist_t * th_llist_new(void *data) +th_llist_t * th_llist_new(void *data) { - qlist_t *res = th_malloc0(sizeof(qlist_t)); + th_llist_t *res = th_malloc0(sizeof(th_llist_t)); res->data = data; return res; } -void th_llist_free_func(qlist_t *list, void (*freefunc)(void *data)) +void th_llist_free_func(th_llist_t *list, void (*freefunc)(void *data)) { - qlist_t *curr = list; + th_llist_t *curr = list; while (curr != NULL) { - qlist_t *next = curr->next; + th_llist_t *next = curr->next; if (freefunc != NULL && curr->data != NULL) freefunc(curr->data); th_free(curr); @@ -254,13 +254,13 @@ } -void th_llist_free(qlist_t *list) +void th_llist_free(th_llist_t *list) { th_llist_free_func(list, NULL); } -void th_llist_append_node(qlist_t **list, qlist_t *node) +void th_llist_append_node(th_llist_t **list, th_llist_t *node) { if (*list != NULL) { @@ -280,9 +280,9 @@ } -qlist_t *th_llist_append(qlist_t **list, void *data) +th_llist_t *th_llist_append(th_llist_t **list, void *data) { - qlist_t *node = th_llist_new(data); + th_llist_t *node = th_llist_new(data); th_llist_append_node(list, node); @@ -290,7 +290,7 @@ } -void th_llist_prepend_node(qlist_t **list, qlist_t *node) +void th_llist_prepend_node(th_llist_t **list, th_llist_t *node) { if (*list != NULL) { @@ -310,9 +310,9 @@ } -qlist_t *th_llist_prepend(qlist_t **list, void *data) +th_llist_t *th_llist_prepend(th_llist_t **list, void *data) { - qlist_t *node = th_llist_new(data); + th_llist_t *node = th_llist_new(data); th_llist_prepend_node(list, node); @@ -352,12 +352,12 @@ */ -void th_llist_delete_node_fast(qlist_t **list, qlist_t *node) +void th_llist_delete_node_fast(th_llist_t **list, th_llist_t *node) { if (node == *list) { // First node in list - qlist_t *tmp = (*list)->next; + th_llist_t *tmp = (*list)->next; if (tmp != NULL) { tmp->num = (*list)->num - 1; @@ -383,13 +383,13 @@ } -void th_llist_delete_node(qlist_t **list, qlist_t *node) +void th_llist_delete_node(th_llist_t **list, th_llist_t *node) { - qlist_t *curr = *list; + th_llist_t *curr = *list; while (curr != NULL) { - qlist_t *next = curr->next; + th_llist_t *next = curr->next; if (curr == node) { th_llist_delete_node_fast(list, curr); @@ -401,13 +401,13 @@ } -void th_llist_delete(qlist_t **list, const void *data) +void th_llist_delete(th_llist_t **list, const void *data) { - qlist_t *curr = *list; + th_llist_t *curr = *list; while (curr != NULL) { - qlist_t *next = curr->next; + th_llist_t *next = curr->next; if (curr->data == data) { th_llist_delete_node_fast(list, curr); @@ -419,9 +419,9 @@ } -qlist_t * th_llist_get_nth(qlist_t *list, const size_t n) +th_llist_t * th_llist_get_nth(th_llist_t *list, const size_t n) { - qlist_t *curr = list; + th_llist_t *curr = list; size_t i; for (i = 0; curr != NULL && i < n; curr = curr->next, i++); @@ -430,7 +430,7 @@ } -size_t th_llist_length(const qlist_t *list) +size_t th_llist_length(const th_llist_t *list) { if (list == NULL) return 0; @@ -439,9 +439,9 @@ } -ssize_t th_llist_position(const qlist_t *list, const qlist_t *node) +ssize_t th_llist_position(const th_llist_t *list, const th_llist_t *node) { - const qlist_t *curr = list; + const th_llist_t *curr = list; ssize_t i = 0; while (curr != NULL) @@ -458,9 +458,9 @@ } -void th_llist_foreach(qlist_t *list, void (*func)(qlist_t *node, void *userdata), void *data) +void th_llist_foreach(th_llist_t *list, void (*func)(th_llist_t *node, void *userdata), void *data) { - qlist_t *curr = list; + th_llist_t *curr = list; while (curr != NULL) { @@ -470,9 +470,9 @@ } -int th_llist_foreach_cond(qlist_t *list, int (*func)(qlist_t *node, void *userdata), void *data, qlist_t **ret) +int th_llist_foreach_cond(th_llist_t *list, int (*func)(th_llist_t *node, void *userdata), void *data, th_llist_t **ret) { - qlist_t *curr = list; + th_llist_t *curr = list; while (curr != NULL) { @@ -489,9 +489,9 @@ } -qlist_t * th_llist_find(qlist_t *list, const void *data) +th_llist_t * th_llist_find(th_llist_t *list, const void *data) { - qlist_t *curr = list; + th_llist_t *curr = list; while (curr != NULL) { @@ -504,9 +504,9 @@ } -qlist_t * th_llist_find_func(qlist_t *list, const void *userdata, int (compare)(const void *, const void *)) +th_llist_t * th_llist_find_func(th_llist_t *list, const void *userdata, int (compare)(const void *, const void *)) { - qlist_t *curr = list; + th_llist_t *curr = list; while (curr != NULL) { diff -r 434c0eae87c9 -r b4e1b15a64e1 th_util.h --- a/th_util.h Wed Jan 28 08:06:02 2015 +0200 +++ b/th_util.h Fri Feb 06 23:04:08 2015 +0200 @@ -144,35 +144,35 @@ /* Doubly linked list handling */ -typedef struct _qlist_t +typedef struct _th_llist_t { void *data; size_t num; - struct _qlist_t *prev, *next; -} qlist_t; + struct _th_llist_t *prev, *next; +} th_llist_t; -qlist_t * th_llist_new(void *data); -void th_llist_free(qlist_t *list); -void th_llist_free_func(qlist_t *list, void (*freefunc)(void *data)); +th_llist_t * th_llist_new(void *data); +void th_llist_free(th_llist_t *list); +void th_llist_free_func(th_llist_t *list, void (*freefunc)(void *data)); -void th_llist_append_node(qlist_t **list, qlist_t *node); -qlist_t * th_llist_append(qlist_t **list, void *data); -void th_llist_prepend_node(qlist_t **list, qlist_t *node); -qlist_t * th_llist_prepend(qlist_t **list, void *data); -void th_llist_delete(qlist_t **list, const void *data); -void th_llist_delete_node(qlist_t **list, qlist_t *node); -void th_llist_delete_node_fast(qlist_t **list, qlist_t *node); +void th_llist_append_node(th_llist_t **list, th_llist_t *node); +th_llist_t * th_llist_append(th_llist_t **list, void *data); +void th_llist_prepend_node(th_llist_t **list, th_llist_t *node); +th_llist_t * th_llist_prepend(th_llist_t **list, void *data); +void th_llist_delete(th_llist_t **list, const void *data); +void th_llist_delete_node(th_llist_t **list, th_llist_t *node); +void th_llist_delete_node_fast(th_llist_t **list, th_llist_t *node); -qlist_t * th_llist_get_nth(qlist_t *list, const size_t n); -size_t th_llist_length(const qlist_t *list); -ssize_t th_llist_position(const qlist_t *list, const qlist_t *node); +th_llist_t * th_llist_get_nth(th_llist_t *list, const size_t n); +size_t th_llist_length(const th_llist_t *list); +ssize_t th_llist_position(const th_llist_t *list, const th_llist_t *node); -void th_llist_foreach(qlist_t *list, void (*func)(qlist_t *node, void *userdata), void *data); -int th_llist_foreach_cond(qlist_t *list, int (*func)(qlist_t *node, void *userdata), void *data, qlist_t **res); +void th_llist_foreach(th_llist_t *list, void (*func)(th_llist_t *node, void *userdata), void *data); +int th_llist_foreach_cond(th_llist_t *list, int (*func)(th_llist_t *node, void *userdata), void *data, th_llist_t **res); -qlist_t * th_llist_find(qlist_t *list, const void *data); -qlist_t * th_llist_find_func(qlist_t *list, const void *userdata, int (compare)(const void *, const void *)); +th_llist_t * th_llist_find(th_llist_t *list, const void *data); +th_llist_t * th_llist_find_func(th_llist_t *list, const void *userdata, int (compare)(const void *, const void *)); /* Ringbuffer implementation