summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2014-08-02 16:47:59 +0200
committerSébastien Helleu <flashcode@flashtux.org>2014-08-02 16:53:12 +0200
commitcf3e0ccbfd0547473c53c2f465e099972e87cc4d (patch)
tree0e64d4cd23ad6f2e139a7d8428b761b7c70a8f5f
parent8a93906beb0b8932c2bddf8fa1a66a53961167cf (diff)
downloadweechat-cf3e0ccbfd0547473c53c2f465e099972e87cc4d.zip
core: fix result of hash function (in hashtables) on 32-bit systems
-rw-r--r--ChangeLog.asciidoc1
-rw-r--r--doc/en/weechat_plugin_api.en.asciidoc4
-rw-r--r--doc/fr/weechat_plugin_api.fr.asciidoc4
-rw-r--r--doc/it/weechat_plugin_api.it.asciidoc4
-rw-r--r--doc/ja/weechat_plugin_api.ja.asciidoc4
-rw-r--r--src/core/wee-hashtable.c24
-rw-r--r--src/core/wee-hashtable.h10
-rw-r--r--src/core/wee-string.c2
-rw-r--r--src/plugins/weechat-plugin.h6
9 files changed, 30 insertions, 29 deletions
diff --git a/ChangeLog.asciidoc b/ChangeLog.asciidoc
index 5fd26bbad..d9285044b 100644
--- a/ChangeLog.asciidoc
+++ b/ChangeLog.asciidoc
@@ -15,6 +15,7 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
== Version 1.0 (under dev)
+* core: fix result of hash function (in hashtables) on 32-bit systems
* core: add terabyte unit for size displayed
* core: fix insert of mouse code in input line after a partial key combo
(closes #130)
diff --git a/doc/en/weechat_plugin_api.en.asciidoc b/doc/en/weechat_plugin_api.en.asciidoc
index 94ad92e0d..4f9c75a8a 100644
--- a/doc/en/weechat_plugin_api.en.asciidoc
+++ b/doc/en/weechat_plugin_api.en.asciidoc
@@ -3366,8 +3366,8 @@ Prototype:
struct t_hashtable *weechat_hashtable_new (int size,
const char *type_keys,
const char *type_values,
- unsigned long (*callback_hash_key)(struct t_hashtable *hashtable,
- const void *key),
+ unsigned long long (*callback_hash_key)(struct t_hashtable *hashtable,
+ const void *key),
int (*callback_keycmp)(struct t_hashtable *hashtable,
const void *key1,
const void *key2));
diff --git a/doc/fr/weechat_plugin_api.fr.asciidoc b/doc/fr/weechat_plugin_api.fr.asciidoc
index fceecf8b9..ec5a50b2a 100644
--- a/doc/fr/weechat_plugin_api.fr.asciidoc
+++ b/doc/fr/weechat_plugin_api.fr.asciidoc
@@ -3415,8 +3415,8 @@ Prototype :
struct t_hashtable *weechat_hashtable_new (int size,
const char *type_keys,
const char *type_values,
- unsigned long (*callback_hash_key)(struct t_hashtable *hashtable,
- const void *key),
+ unsigned long long (*callback_hash_key)(struct t_hashtable *hashtable,
+ const void *key),
int (*callback_keycmp)(struct t_hashtable *hashtable,
const void *key1,
const void *key2));
diff --git a/doc/it/weechat_plugin_api.it.asciidoc b/doc/it/weechat_plugin_api.it.asciidoc
index 5dfe9a22d..1e9f5a3cd 100644
--- a/doc/it/weechat_plugin_api.it.asciidoc
+++ b/doc/it/weechat_plugin_api.it.asciidoc
@@ -3440,8 +3440,8 @@ Prototipo:
struct t_hashtable *weechat_hashtable_new (int size,
const char *type_keys,
const char *type_values,
- unsigned long (*callback_hash_key)(struct t_hashtable *hashtable,
- const void *key),
+ unsigned long long (*callback_hash_key)(struct t_hashtable *hashtable,
+ const void *key),
int (*callback_keycmp)(struct t_hashtable *hashtable,
const void *key1,
const void *key2));
diff --git a/doc/ja/weechat_plugin_api.ja.asciidoc b/doc/ja/weechat_plugin_api.ja.asciidoc
index 98bbe9a64..8432411d5 100644
--- a/doc/ja/weechat_plugin_api.ja.asciidoc
+++ b/doc/ja/weechat_plugin_api.ja.asciidoc
@@ -3362,8 +3362,8 @@ _WeeChat バージョン 0.3.3 以上で利用可。_
struct t_hashtable *weechat_hashtable_new (int size,
const char *type_keys,
const char *type_values,
- unsigned long (*callback_hash_key)(struct t_hashtable *hashtable,
- const void *key),
+ unsigned long long (*callback_hash_key)(struct t_hashtable *hashtable,
+ const void *key),
int (*callback_keycmp)(struct t_hashtable *hashtable,
const void *key1,
const void *key2));
diff --git a/src/core/wee-hashtable.c b/src/core/wee-hashtable.c
index e77d4c624..9ec9546b7 100644
--- a/src/core/wee-hashtable.c
+++ b/src/core/wee-hashtable.c
@@ -72,10 +72,10 @@ hashtable_get_type (const char *type)
* Returns the hash of the string.
*/
-unsigned long
+unsigned long long
hashtable_hash_key_djb2 (const char *string)
{
- unsigned long hash;
+ unsigned long long hash;
const char *ptr_string;
hash = 5381;
@@ -93,28 +93,28 @@ hashtable_hash_key_djb2 (const char *string)
* Returns the hash of the key, depending on the type.
*/
-unsigned long
+unsigned long long
hashtable_hash_key_default_cb (struct t_hashtable *hashtable, const void *key)
{
- unsigned long hash;
+ unsigned long long hash;
hash = 0;
switch (hashtable->type_keys)
{
case HASHTABLE_INTEGER:
- hash = (unsigned long)(*((int *)key));
+ hash = (unsigned long long)(*((int *)key));
break;
case HASHTABLE_STRING:
hash = hashtable_hash_key_djb2 ((const char *)key);
break;
case HASHTABLE_POINTER:
- hash = (unsigned long)((void *)key);
+ hash = (unsigned long long)((unsigned long)((void *)key));
break;
case HASHTABLE_BUFFER:
break;
case HASHTABLE_TIME:
- hash = (unsigned long)(*((time_t *)key));
+ hash = (unsigned long long)(*((time_t *)key));
break;
case HASHTABLE_NUM_TYPES:
break;
@@ -375,7 +375,7 @@ hashtable_set_with_size (struct t_hashtable *hashtable,
const void *key, int key_size,
const void *value, int value_size)
{
- unsigned long hash;
+ unsigned long long hash;
struct t_hashtable_item *ptr_item, *pos_item, *new_item;
if (!hashtable || !key
@@ -469,9 +469,9 @@ hashtable_set (struct t_hashtable *hashtable,
struct t_hashtable_item *
hashtable_get_item (struct t_hashtable *hashtable, const void *key,
- unsigned long *hash)
+ unsigned long long *hash)
{
- unsigned long key_hash;
+ unsigned long long key_hash;
struct t_hashtable_item *ptr_item;
if (!hashtable || !key)
@@ -1109,7 +1109,7 @@ hashtable_add_to_infolist (struct t_hashtable *hashtable,
void
hashtable_remove_item (struct t_hashtable *hashtable,
struct t_hashtable_item *item,
- unsigned long hash)
+ unsigned long long hash)
{
if (!hashtable || !item)
return;
@@ -1139,7 +1139,7 @@ void
hashtable_remove (struct t_hashtable *hashtable, const void *key)
{
struct t_hashtable_item *ptr_item;
- unsigned long hash;
+ unsigned long long hash;
if (!hashtable || !key)
return;
diff --git a/src/core/wee-hashtable.h b/src/core/wee-hashtable.h
index 0473f796f..20f6ec05b 100644
--- a/src/core/wee-hashtable.h
+++ b/src/core/wee-hashtable.h
@@ -23,8 +23,8 @@
struct t_hashtable;
struct t_infolist_item;
-typedef unsigned long (t_hashtable_hash_key)(struct t_hashtable *hashtable,
- const void *key);
+typedef unsigned long long (t_hashtable_hash_key)(struct t_hashtable *hashtable,
+ const void *key);
typedef int (t_hashtable_keycmp)(struct t_hashtable *hashtable,
const void *key1, const void *key2);
typedef void (t_hashtable_free_key)(struct t_hashtable *hashtable,
@@ -40,7 +40,7 @@ typedef void (t_hashtable_map_string)(void *data,
/*
* Hashtable is a structure with an array "htable", each entry is a pointer
- * to a linked list, and it is read with hashed key (as unsigned long).
+ * to a linked list, and it is read with hashed key (as unsigned long long).
* Keys with same hashed key are grouped in a linked list pointed by htable.
* The htable is not sorted, the linked list is sorted.
*
@@ -112,7 +112,7 @@ struct t_hashtable
/* never asked) */
};
-extern unsigned long hashtable_hash_key_djb2 (const char *string);
+extern unsigned long long hashtable_hash_key_djb2 (const char *string);
extern struct t_hashtable *hashtable_new (int size,
const char *type_keys,
const char *type_values,
@@ -128,7 +128,7 @@ extern struct t_hashtable_item *hashtable_set (struct t_hashtable *hashtable,
const void *value);
extern struct t_hashtable_item *hashtable_get_item (struct t_hashtable *hashtable,
const void *key,
- unsigned long *hash);
+ unsigned long long *hash);
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/core/wee-string.c b/src/core/wee-string.c
index 8a2c643d1..79e757db9 100644
--- a/src/core/wee-string.c
+++ b/src/core/wee-string.c
@@ -2779,7 +2779,7 @@ string_replace_with_callback (const char *string,
* Returns the hash of the shared string (variant of djb2).
*/
-unsigned long
+unsigned long long
string_shared_hash_key (struct t_hashtable *hashtable,
const void *key)
{
diff --git a/src/plugins/weechat-plugin.h b/src/plugins/weechat-plugin.h
index f37dd76c4..ad619e9c2 100644
--- a/src/plugins/weechat-plugin.h
+++ b/src/plugins/weechat-plugin.h
@@ -57,7 +57,7 @@ struct timeval;
* please change the date with current one; for a second change at same
* date, increment the 01, otherwise please keep 01.
*/
-#define WEECHAT_PLUGIN_API_VERSION "20140610-01"
+#define WEECHAT_PLUGIN_API_VERSION "20140802-01"
/* macros for defining plugin infos */
#define WEECHAT_PLUGIN_NAME(__name) \
@@ -339,8 +339,8 @@ struct t_weechat_plugin
struct t_hashtable *(*hashtable_new) (int size,
const char *type_keys,
const char *type_values,
- unsigned long (*callback_hash_key)(struct t_hashtable *hashtable,
- const void *key),
+ unsigned long long (*callback_hash_key)(struct t_hashtable *hashtable,
+ const void *key),
int (*callback_keycmp)(struct t_hashtable *hashtable,
const void *key1,
const void *key2));