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