summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog.adoc2
-rw-r--r--src/core/wee-hashtable.c3
-rw-r--r--tests/unit/core/test-core-hashtable.cpp11
3 files changed, 11 insertions, 5 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index 1159bbf2c..4c759d615 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -31,7 +31,7 @@ New features::
Bug fixes::
- * core: use fixed-width integer for computing nick hash (issue #1394)
+ * core: use fixed-width integer for computing nick and hashtable DJB2 key hashes (issue #1394)
* core: create or update option weechat.notify.xxx when function buffer_set is called with "notify" property (issue #1390)
* core: fix memory leak in case of error when building content of bar item for display (issue #1384)
* core: send command line parameter to plugins only if the name starts with the plugin name followed by a colon
diff --git a/src/core/wee-hashtable.c b/src/core/wee-hashtable.c
index ad51c3ae9..037a3d39a 100644
--- a/src/core/wee-hashtable.c
+++ b/src/core/wee-hashtable.c
@@ -24,6 +24,7 @@
#endif
#include <stdlib.h>
+#include <stdint.h>
#include <string.h>
#include <time.h>
@@ -75,7 +76,7 @@ hashtable_get_type (const char *type)
unsigned long long
hashtable_hash_key_djb2 (const char *string)
{
- unsigned long long hash;
+ uint64_t hash;
const char *ptr_string;
hash = 5381;
diff --git a/tests/unit/core/test-core-hashtable.cpp b/tests/unit/core/test-core-hashtable.cpp
index d7bedd6ef..3d51e23c3 100644
--- a/tests/unit/core/test-core-hashtable.cpp
+++ b/tests/unit/core/test-core-hashtable.cpp
@@ -28,9 +28,11 @@ extern "C"
#include "src/plugins/plugin.h"
}
-#define HASHTABLE_TEST_KEY "test"
-#define HASHTABLE_TEST_KEY_HASH 5849825121ULL
-#define HASHTABLE_TEST_VALUE "this is a value"
+#define HASHTABLE_TEST_KEY "test"
+#define HASHTABLE_TEST_KEY_HASH 5849825121ULL
+#define HASHTABLE_TEST_KEY_LONG "abcdefghijklmnopqrstuvwxyz"
+#define HASHTABLE_TEST_KEY_LONG_HASH 11232856562070989738ULL
+#define HASHTABLE_TEST_VALUE "this is a value"
TEST_GROUP(CoreHashtable)
{
@@ -47,6 +49,9 @@ TEST(CoreHashtable, HashDbj2)
hash = hashtable_hash_key_djb2 (HASHTABLE_TEST_KEY);
CHECK(hash == HASHTABLE_TEST_KEY_HASH);
+
+ hash = hashtable_hash_key_djb2 (HASHTABLE_TEST_KEY_LONG);
+ CHECK(hash == HASHTABLE_TEST_KEY_LONG_HASH);
}
/*