src/hash_key.c

changeset 604
056e5f592d84
parent 603
c49104015a6b
child 628
1e2be40f0cb5
     1.1 --- a/src/hash_key.c	Sun Nov 06 14:46:59 2022 +0100
     1.2 +++ b/src/hash_key.c	Sun Nov 06 16:07:32 2022 +0100
     1.3 @@ -30,8 +30,13 @@
     1.4  #include <string.h>
     1.5  
     1.6  void cx_hash_murmur(CxHashKey *key) {
     1.7 +    unsigned char const *data = key->data.cbytes;
     1.8 +    if (data == NULL) {
     1.9 +        /* extension: special value for NULL */
    1.10 +        key->hash = 1574210520u;
    1.11 +        return;
    1.12 +    }
    1.13      size_t len = key->len;
    1.14 -    unsigned char const *data = key->data.cbytes;
    1.15  
    1.16      unsigned m = 0x5bd1e995;
    1.17      unsigned r = 24;
    1.18 @@ -79,7 +84,7 @@
    1.19  CxHashKey cx_hash_key_str(char const *str) {
    1.20      CxHashKey key;
    1.21      key.data.cstr = str;
    1.22 -    key.len = str == NULL ? 0 : (1 + strlen(str));
    1.23 +    key.len = str == NULL ? 0 : strlen(str);
    1.24      cx_hash_murmur(&key);
    1.25      return key;
    1.26  }

mercurial