diff --git a/src/main/event.c b/src/main/event.c index a81688aa0..5847923ea 100644 --- a/src/main/event.c +++ b/src/main/event.c @@ -117,7 +117,7 @@ register_event(char *name) } int -get_event_id(char *name) +get_event_id(const char *name) { struct hash_item *item; int namelen; diff --git a/src/main/event.h b/src/main/event.h index 724c55471..b63fcdb02 100644 --- a/src/main/event.h +++ b/src/main/event.h @@ -95,7 +95,7 @@ void unregister_event_hooks(struct event_hook_info *hooks); * unregistration), thus it may be cached intermediatelly. */ /* It returns the event id on success or a negative number upon failure * (ie. there is no such event). */ -int get_event_id(char *name); +int get_event_id(const char *name); /* This looks up the events table and returns the name of a given event * @id. */ diff --git a/src/util/hash.c b/src/util/hash.c index b34286360..ed3c80606 100644 --- a/src/util/hash.c +++ b/src/util/hash.c @@ -25,7 +25,7 @@ #define hash_mask(n) (hash_size(n) - 1) #define hash_size(n) (1 << (n)) -static hash_value_T strhash(char *k, unsigned int length, hash_value_T initval); +static hash_value_T strhash(const char *k, unsigned int length, hash_value_T initval); static inline struct hash * init_hash(unsigned int width, hash_func_T func) @@ -82,7 +82,7 @@ free_hash(struct hash **hashp) /** @returns hash_item if ok, NULL if error. * @relates hash */ struct hash_item * -add_hash_item(struct hash *hash, char *key, unsigned int keylen, +add_hash_item(struct hash *hash, const char *key, unsigned int keylen, void *value) { hash_value_T hashval; @@ -103,7 +103,7 @@ add_hash_item(struct hash *hash, char *key, unsigned int keylen, /** @relates hash */ struct hash_item * -get_hash_item(struct hash *hash, char *key, unsigned int keylen) +get_hash_item(struct hash *hash, const char *key, unsigned int keylen) { struct list_head *list; struct hash_item *item; @@ -151,7 +151,7 @@ del_hash_item(struct hash *hash, struct hash_item *item) * @param length the length of the key * @param initval the previous hash, or an arbitrary value */ static hash_value_T -strhash(char *k, +strhash(const char *k, unsigned int length, hash_value_T initval) { diff --git a/src/util/hash.h b/src/util/hash.h index 9f11444d3..624144266 100644 --- a/src/util/hash.h +++ b/src/util/hash.h @@ -11,12 +11,12 @@ extern "C" { * happen when this will be of other length, but it should still work ok. * --pasky */ typedef unsigned long hash_value_T; -typedef hash_value_T (* hash_func_T)(char *key, unsigned int keylen, hash_value_T magic); +typedef hash_value_T (* hash_func_T)(const char *key, unsigned int keylen, hash_value_T magic); struct hash_item { LIST_HEAD(struct hash_item); - char *key; + const char *key; unsigned int keylen; void *value; }; @@ -31,8 +31,8 @@ struct hash *init_hash8(void); void free_hash(struct hash **hashp); -struct hash_item *add_hash_item(struct hash *hash, char *key, unsigned int keylen, void *value); -struct hash_item *get_hash_item(struct hash *hash, char *key, unsigned int keylen); +struct hash_item *add_hash_item(struct hash *hash, const char *key, unsigned int keylen, void *value); +struct hash_item *get_hash_item(struct hash *hash, const char *key, unsigned int keylen); void del_hash_item(struct hash *hash, struct hash_item *item); /** @relates hash */