From 31b3893a72493c849c67aa1cd8c7c4c457ca360c Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 28 Apr 2014 17:56:08 +0200 Subject: [PATCH] kvlist: constify arguments Signed-off-by: Felix Fietkau --- kvlist.c | 8 ++++---- kvlist.h | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/kvlist.c b/kvlist.c index 4f56a38..e0a8acb 100644 --- a/kvlist.c +++ b/kvlist.c @@ -24,17 +24,17 @@ #include "kvlist.h" -int kvlist_strlen(struct kvlist *kv, void *data) +int kvlist_strlen(struct kvlist *kv, const void *data) { return strlen(data) + 1; } -int kvlist_blob_len(struct kvlist *kv, void *data) +int kvlist_blob_len(struct kvlist *kv, const void *data) { return blob_pad_len(data); } -void kvlist_init(struct kvlist *kv, int (*get_len)(struct kvlist *kv, void *data)) +void kvlist_init(struct kvlist *kv, int (*get_len)(struct kvlist *kv, const void *data)) { avl_init(&kv->avl, avl_strcmp, false, NULL); kv->get_len = get_len; @@ -71,7 +71,7 @@ bool kvlist_delete(struct kvlist *kv, const char *name) return !!node; } -void kvlist_set(struct kvlist *kv, const char *name, void *data) +void kvlist_set(struct kvlist *kv, const char *name, const void *data) { struct kvlist_node *node; char *name_buf; diff --git a/kvlist.h b/kvlist.h index a4e1b1d..0d35b46 100644 --- a/kvlist.h +++ b/kvlist.h @@ -23,7 +23,7 @@ struct kvlist { struct avl_tree avl; - int (*get_len)(struct kvlist *kv, void *data); + int (*get_len)(struct kvlist *kv, const void *data); }; struct kvlist_node { @@ -42,13 +42,13 @@ struct kvlist_node { value = (void *) (__avl_list_to_kv(__ptr_to_kv(value)->avl.list.next))->data, \ name = (const char *) __ptr_to_kv(value)->avl.key) -void kvlist_init(struct kvlist *kv, int (*get_len)(struct kvlist *kv, void *data)); +void kvlist_init(struct kvlist *kv, int (*get_len)(struct kvlist *kv, const void *data)); void kvlist_free(struct kvlist *kv); void *kvlist_get(struct kvlist *kv, const char *name); -void kvlist_set(struct kvlist *kv, const char *name, void *data); +void kvlist_set(struct kvlist *kv, const char *name, const void *data); bool kvlist_delete(struct kvlist *kv, const char *name); -int kvlist_strlen(struct kvlist *kv, void *data); -int kvlist_blob_len(struct kvlist *kv, void *data); +int kvlist_strlen(struct kvlist *kv, const void *data); +int kvlist_blob_len(struct kvlist *kv, const void *data); #endif -- 2.25.1