diff --git a/doc/en/weechat_plugin_api.en.txt b/doc/en/weechat_plugin_api.en.txt index 440317fdb..3ee15b6a4 100644 --- a/doc/en/weechat_plugin_api.en.txt +++ b/doc/en/weechat_plugin_api.en.txt @@ -2883,8 +2883,8 @@ Prototype: [source,C] ---------------------------------------- int weechat_hashtable_set_with_size (struct t_hashtable *hashtable, - void *key, int key_size, - void *value, int value_size); + const void *key, int key_size, + const void *value, int value_size); ---------------------------------------- Arguments: @@ -2924,7 +2924,7 @@ Prototype: [source,C] ---------------------------------------- int weechat_hashtable_set (struct t_hashtable *hashtable, - void *key, void *value); + const void *key, const void *value); ---------------------------------------- Arguments: diff --git a/doc/fr/weechat_plugin_api.fr.txt b/doc/fr/weechat_plugin_api.fr.txt index 18cf35346..b78020fb4 100644 --- a/doc/fr/weechat_plugin_api.fr.txt +++ b/doc/fr/weechat_plugin_api.fr.txt @@ -2914,8 +2914,8 @@ Prototype : [source,C] ---------------------------------------- int weechat_hashtable_set_with_size (struct t_hashtable *hashtable, - void *key, int key_size, - void *value, int value_size); + const void *key, int key_size, + const void *value, int value_size); ---------------------------------------- Paramètres : @@ -2955,7 +2955,7 @@ Prototype : [source,C] ---------------------------------------- int weechat_hashtable_set (struct t_hashtable *hashtable, - void *key, void *value); + const void *key, const void *value); ---------------------------------------- Paramètres : diff --git a/doc/it/weechat_plugin_api.it.txt b/doc/it/weechat_plugin_api.it.txt index 1ccd4d5c9..cd7b45bf8 100644 --- a/doc/it/weechat_plugin_api.it.txt +++ b/doc/it/weechat_plugin_api.it.txt @@ -2919,8 +2919,8 @@ Prototipo: [source,C] ---------------------------------------- int weechat_hashtable_set_with_size (struct t_hashtable *hashtable, - void *key, int key_size, - void *value, int value_size); + const void *key, int key_size, + const void *value, int value_size); ---------------------------------------- Arguments: @@ -2960,7 +2960,7 @@ Prototipo: [source,C] ---------------------------------------- int weechat_hashtable_set (struct t_hashtable *hashtable, - void *key, void *value); + const void *key, const void *value); ---------------------------------------- Argomenti: diff --git a/src/core/wee-hashtable.c b/src/core/wee-hashtable.c index 4575f3d95..f11e7672c 100644 --- a/src/core/wee-hashtable.c +++ b/src/core/wee-hashtable.c @@ -158,7 +158,8 @@ hashtable_new (int size, */ void -hashtable_alloc_type (enum t_hashtable_type type, void *value, int size_value, +hashtable_alloc_type (enum t_hashtable_type type, + const void *value, int size_value, void **pointer, int *size) { switch (type) @@ -179,7 +180,7 @@ hashtable_alloc_type (enum t_hashtable_type type, void *value, int size_value, *size = (*pointer) ? strlen (*pointer) + 1 : 0; break; case HASHTABLE_POINTER: - *pointer = value; + *pointer = (void *)value; *size = sizeof (void *); break; case HASHTABLE_BUFFER: @@ -239,8 +240,8 @@ hashtable_free_type (enum t_hashtable_type type, void *value) int hashtable_set_with_size (struct t_hashtable *hashtable, - void *key, int key_size, - void *value, int value_size) + const void *key, int key_size, + const void *value, int value_size) { unsigned int hash; struct t_hashtable_item *ptr_item, *pos_item, *new_item; @@ -319,7 +320,8 @@ hashtable_set_with_size (struct t_hashtable *hashtable, */ int -hashtable_set (struct t_hashtable *hashtable, void *key, void *value) +hashtable_set (struct t_hashtable *hashtable, + const void *key, const void *value) { return hashtable_set_with_size (hashtable, key, 0, value, 0); } diff --git a/src/core/wee-hashtable.h b/src/core/wee-hashtable.h index fbc06eb66..baad83773 100644 --- a/src/core/wee-hashtable.h +++ b/src/core/wee-hashtable.h @@ -109,10 +109,10 @@ extern struct t_hashtable *hashtable_new (int size, t_hashtable_hash_key *hash_key_cb, t_hashtable_keycmp *keycmp_cb); extern int hashtable_set_with_size (struct t_hashtable *hashtable, - void *key, int key_size, - void *value, int value_size); -extern int hashtable_set (struct t_hashtable *hashtable, void *key, - void *value); + const void *key, int key_size, + const void *value, int value_size); +extern int hashtable_set (struct t_hashtable *hashtable, const void *key, + const void *value); extern void *hashtable_get (struct t_hashtable *hashtable, const void *key); extern int hashtable_has_key (struct t_hashtable *hashtable, const void *key); extern void hashtable_map (struct t_hashtable *hashtable, diff --git a/src/gui/gui-buffer.c b/src/gui/gui-buffer.c index f62fc4b2c..bf742b5a7 100644 --- a/src/gui/gui-buffer.c +++ b/src/gui/gui-buffer.c @@ -140,8 +140,7 @@ gui_buffer_local_var_add (struct t_gui_buffer *buffer, const char *name, return; ptr_value = hashtable_get (buffer->local_variables, name); - hashtable_set (buffer->local_variables, - (void *)name, (void *)value); + hashtable_set (buffer->local_variables, name, value); hook_signal_send ((ptr_value) ? "buffer_localvar_changed" : "buffer_localvar_added", WEECHAT_HOOK_SIGNAL_POINTER, buffer); @@ -478,9 +477,8 @@ gui_buffer_new (struct t_weechat_plugin *plugin, NULL, NULL); hashtable_set (new_buffer->local_variables, - "plugin", (void *)plugin_get_name (plugin)); - hashtable_set (new_buffer->local_variables, - "name", (void *)name); + "plugin", plugin_get_name (plugin)); + hashtable_set (new_buffer->local_variables, "name", name); /* add buffer to buffers list */ first_buffer_creation = (gui_buffers == NULL); diff --git a/src/plugins/relay/relay-client-irc.c b/src/plugins/relay/relay-client-irc.c index 1e7404180..e0ae75210 100644 --- a/src/plugins/relay/relay-client-irc.c +++ b/src/plugins/relay/relay-client-irc.c @@ -114,7 +114,7 @@ relay_client_irc_parse_message (const char *message) weechat_prefix ("error"), RELAY_PLUGIN_NAME); goto end; } - weechat_hashtable_set (hash_msg, "message", (char *)message); + weechat_hashtable_set (hash_msg, "message", message); hash_parsed = weechat_info_get_hashtable ("irc_parse_message", hash_msg); if (!hash_parsed) diff --git a/src/plugins/scripts/lua/weechat-lua.c b/src/plugins/scripts/lua/weechat-lua.c index 3486239d4..f22fa9389 100644 --- a/src/plugins/scripts/lua/weechat-lua.c +++ b/src/plugins/scripts/lua/weechat-lua.c @@ -131,8 +131,8 @@ weechat_lua_tohashtable (lua_State *interpreter, int index, int hashtable_size) while (lua_next (interpreter, index - 1) != 0) { weechat_hashtable_set (hashtable, - (char *)lua_tostring (interpreter, -2), - (char *)lua_tostring (interpreter, -1)); + lua_tostring (interpreter, -2), + lua_tostring (interpreter, -1)); /* remove value from stack (keep key for next iteration) */ lua_pop (interpreter, 1); } diff --git a/src/plugins/scripts/python/weechat-python.c b/src/plugins/scripts/python/weechat-python.c index fb8d46779..dadf38fb7 100644 --- a/src/plugins/scripts/python/weechat-python.c +++ b/src/plugins/scripts/python/weechat-python.c @@ -148,7 +148,7 @@ weechat_python_dict_to_hashtable (PyObject *dict, int hashtable_size) { str_key = PyString_AsString (key); str_value = PyString_AsString (value); - weechat_hashtable_set (hashtable, (void *)str_key, (void *)str_value); + weechat_hashtable_set (hashtable, str_key, str_value); } return hashtable; diff --git a/src/plugins/scripts/tcl/weechat-tcl.c b/src/plugins/scripts/tcl/weechat-tcl.c index 9dfd05a0e..27a3190d1 100644 --- a/src/plugins/scripts/tcl/weechat-tcl.c +++ b/src/plugins/scripts/tcl/weechat-tcl.c @@ -153,8 +153,8 @@ weechat_tcl_dict_to_hashtable (Tcl_Interp *interp, Tcl_Obj *dict, for (; !done ; Tcl_DictObjNext(&search, &key, &value, &done)) { weechat_hashtable_set (hashtable, - (void *)Tcl_GetString (key), - (void *)Tcl_GetString (value)); + Tcl_GetString (key), + Tcl_GetString (value)); } } Tcl_DictObjDone(&search); diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h index 6b340f677..d8a080000 100644 --- a/src/plugins/weechat-plugin.h +++ b/src/plugins/weechat-plugin.h @@ -45,7 +45,7 @@ struct timeval; */ /* API version (used to check that plugin has same API and can be loaded) */ -#define WEECHAT_PLUGIN_API_VERSION "20101011-01" +#define WEECHAT_PLUGIN_API_VERSION "20101017-01" /* macros for defining plugin infos */ #define WEECHAT_PLUGIN_NAME(__name) \ @@ -260,10 +260,10 @@ struct t_weechat_plugin const void *key1, const void *key2)); int (*hashtable_set_with_size) (struct t_hashtable *hashtable, - void *key, int key_size, - void *value, int value_size); - int (*hashtable_set) (struct t_hashtable *hashtable, void *key, - void *value); + const void *key, int key_size, + const void *value, int value_size); + int (*hashtable_set) (struct t_hashtable *hashtable, const void *key, + const void *value); void *(*hashtable_get) (struct t_hashtable *hashtable, const void *key); int (*hashtable_has_key) (struct t_hashtable *hashtable, const void *key); void (*hashtable_map) (struct t_hashtable *hashtable,