summaryrefslogtreecommitdiffstats
path: root/src/utils/list.h
diff options
context:
space:
mode:
authorJohann CAHIER <johann.cahier@iot.bzh>2019-05-16 17:35:59 +0200
committerJohann CAHIER <johann.cahier@iot.bzh>2019-05-24 10:04:47 +0200
commit5dd410aab93c4ea5c3c04662585c072172ea5547 (patch)
tree3e8a46b7bf643bc918cda5a25872d5b43d4b632c /src/utils/list.h
parent8c0851b6fdf7690ae25a6fbd83e0f2795a8cdf8b (diff)
Better memory management in chained list
key is now managed internally, using a copy. add_elt() / add_key() now provide a 'suffix' parameter. If suffix is given, it is appended to the key. If NULL, or empty string ("") is given, nothing is appended. NOTE : value is still owned by json object. Bug-AGL: SPEC-2416 Change-Id: I624a2dd211801c2d24b2c6739f2c7536a047ea32 Signed-off-by: Johann CAHIER <johann.cahier@iot.bzh>
Diffstat (limited to 'src/utils/list.h')
-rw-r--r--src/utils/list.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/utils/list.h b/src/utils/list.h
index 9f93cb6..c0d559f 100644
--- a/src/utils/list.h
+++ b/src/utils/list.h
@@ -21,17 +21,17 @@
#include <json-c/json.h>
struct list {
- const char *key;
+ char *key;
json_object *value;
struct list *next;
};
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, const char* suffix, json_object *value);
+void add_key(struct list **l, const char *key, const char* suffix);
int set_value(struct list *l, json_object *val, int index);
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);
+struct list *find_elt_from_key(struct list *l, const char *suffixed_key);
+json_object *find_key_value(struct list *l, const char *suffixed_key);
#endif