From 5d50f0426699a06b5720e10f1feaef35c8b59f57 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Sat, 14 Apr 2018 01:57:17 +0200 Subject: Improve writer/reader processing - Handle indefinite number and kind of tags and fields for a metric - Include only once header files - Cleaning and ordering code Change-Id: I14a4f0e6e1626971bff73ce7d9ac067bda69cfc4 Signed-off-by: Romain Forlot --- src/utils/list.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/utils/list.c') diff --git a/src/utils/list.c b/src/utils/list.c index da97e42..bd7eeac 100644 --- a/src/utils/list.c +++ b/src/utils/list.c @@ -28,39 +28,39 @@ void destroy_list(struct list *l) } } -void add_elt(struct list *l, const char *key, json_object *value) +void add_elt(struct list **l, const char *key, json_object *value) { struct list *new_elt = malloc(sizeof(struct list)); new_elt->key = key; new_elt->value = value; new_elt->next = NULL; - if(l) { - while(l->next != NULL) { - l = l->next; + if(*l) { + while((*l)->next != NULL) { + *l = (*l)->next; } - l->next = new_elt; + (*l)->next = new_elt; } else { - l = new_elt; + *l = new_elt; } } -void add_key(struct list *l, const char *key) +void add_key(struct list **l, const char *key) { struct list *new_elt = malloc(sizeof(struct list)); new_elt->key = key; new_elt->value = NULL; new_elt->next = NULL; - if(l) { - while(l->next != NULL) { - l = l->next; + if(*l) { + while((*l)->next != NULL) { + *l = (*l)->next; } - l->next = new_elt; + (*l)->next = new_elt; } else { - l = new_elt; + *l = new_elt; } } -- cgit 1.2.3-korg