src/ucx/cx/hash_key.h

changeset 490
d218607f5a7e
parent 438
22eca559aded
--- a/src/ucx/cx/hash_key.h	Sat Mar 25 17:18:51 2023 +0100
+++ b/src/ucx/cx/hash_key.h	Fri May 05 18:02:11 2023 +0200
@@ -38,7 +38,7 @@
 #ifndef UCX_HASH_KEY_H
 #define UCX_HASH_KEY_H
 
-#include "stddef.h"
+#include "common.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -47,14 +47,7 @@
 /** Internal structure for a key within a hash map. */
 struct cx_hash_key_s {
     /** The key data. */
-    union {
-        unsigned char *bytes;
-        unsigned char const *cbytes;
-        char *str;
-        char const *cstr;
-        void *obj;
-        void const *cobj;
-    } data;
+    void const *data;
     /**
      * The key data length.
      */
@@ -121,6 +114,14 @@
         size_t len
 );
 
+/**
+ * Computes a hash key from a UCX string.
+ *
+ * @param str the string
+ * @return the hash key
+ */
+#define cx_hash_key_cxstr(str) cx_hash_key((void*)(str).ptr, (str).length)
+
 #ifdef __cplusplus
 } // extern "C"
 #endif

mercurial