aboutsummaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/list.c24
-rw-r--r--src/utils/list.h4
2 files changed, 14 insertions, 14 deletions
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;
}
}
diff --git a/src/utils/list.h b/src/utils/list.h
index dcb01bd..7cacbed 100644
--- a/src/utils/list.h
+++ b/src/utils/list.h
@@ -27,8 +27,8 @@ struct list {
};
void destroy_list(struct list *l);
-void add_elt(struct list *l, const char *key, json_object *value);
-void add_key(struct list *l, const char *key);
+void add_elt(struct list **l, const char *key, json_object *value);
+void add_key(struct list **l, const char *key);
struct list *get_elt(struct list *l, int index);
struct list *find_elt_from_key(struct list *l, const char *key);
json_object *find_key_value(struct list *l, const char *key);