ucx/hash_key.c

changeset 113
dde28a806552
parent 112
c3f2f16fa4b8
--- a/ucx/hash_key.c	Sun Oct 19 21:20:08 2025 +0200
+++ b/ucx/hash_key.c	Mon Nov 10 21:52:51 2025 +0100
@@ -105,6 +105,22 @@
     return key;
 }
 
+CxHashKey cx_hash_key_ustr(unsigned const char *str) {
+    CxHashKey key;
+    key.data = str;
+    key.len = str == NULL ? 0 : strlen((const char*)str);
+    cx_hash_murmur(&key);
+    return key;
+}
+
+CxHashKey cx_hash_key_cxstr(cxstring str) {
+    return cx_hash_key(str.ptr, str.length);
+}
+
+CxHashKey cx_hash_key_mutstr(cxmutstr str) {
+    return cx_hash_key(str.ptr, str.length);
+}
+
 CxHashKey cx_hash_key_bytes(
         const unsigned char *bytes,
         size_t len
@@ -143,7 +159,9 @@
     return key;
 }
 
-int cx_hash_key_cmp(const CxHashKey *left, const CxHashKey *right) {
+int cx_hash_key_cmp(const void *l, const void *r) {
+    const CxHashKey *left = l;
+    const CxHashKey *right = r;
     int d;
     d = cx_vcmp_uint64(left->hash, right->hash);
     if (d != 0) return d;

mercurial