src/ucx/hash_key.c

changeset 416
e2093ca0ef90
parent 415
d938228c382e
child 438
22eca559aded
--- a/src/ucx/hash_key.c	Sun Nov 06 15:53:32 2022 +0100
+++ b/src/ucx/hash_key.c	Sun Nov 06 16:59:39 2022 +0100
@@ -30,8 +30,13 @@
 #include <string.h>
 
 void cx_hash_murmur(CxHashKey *key) {
+    unsigned char const *data = key->data.cbytes;
+    if (data == NULL) {
+        /* extension: special value for NULL */
+        key->hash = 1574210520u;
+        return;
+    }
     size_t len = key->len;
-    unsigned char const *data = key->data.cbytes;
 
     unsigned m = 0x5bd1e995;
     unsigned r = 24;
@@ -96,11 +101,11 @@
 }
 
 CxHashKey cx_hash_key(
-        void *obj,
+        void const *obj,
         size_t len
 ) {
     CxHashKey key;
-    key.data.obj = obj;
+    key.data.cobj = obj;
     key.len = len;
     cx_hash_murmur(&key);
     return key;

mercurial