1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-04 00:33:13 +02:00

Use const void * for keys and values in some hashtable functions

This commit is contained in:
Sebastien Helleu
2010-10-17 10:39:51 +02:00
parent eff0f9abdb
commit ebf94445b9
11 changed files with 34 additions and 34 deletions
+3 -3
View File
@@ -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:
+3 -3
View File
@@ -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 :
+3 -3
View File
@@ -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:
+7 -5
View File
@@ -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);
}
+4 -4
View File
@@ -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,
+3 -5
View File
@@ -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);
+1 -1
View File
@@ -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)
+2 -2
View File
@@ -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);
}
+1 -1
View File
@@ -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;
+2 -2
View File
@@ -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);
+5 -5
View File
@@ -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,