fix missing const in cx_hash_key signature

Sun, 06 Nov 2022 14:46:59 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 06 Nov 2022 14:46:59 +0100
changeset 603
c49104015a6b
parent 602
3b071ea0e9cf
child 604
056e5f592d84

fix missing const in cx_hash_key signature

src/cx/hash_key.h file | annotate | diff | comparison | revisions
src/hash_key.c file | annotate | diff | comparison | revisions
test/test_hash_key.cpp file | annotate | diff | comparison | revisions
--- a/src/cx/hash_key.h	Sun Nov 06 14:17:33 2022 +0100
+++ b/src/cx/hash_key.h	Sun Nov 06 14:46:59 2022 +0100
@@ -50,9 +50,10 @@
     union {
         unsigned char *bytes;
         unsigned char const *cbytes;
+        char *str;
         char const *cstr;
-        char *str;
         void *obj;
+        void const *cobj;
     } data;
     /**
      * The key data length.
@@ -114,7 +115,7 @@
  */
 __attribute__((__warn_unused_result__))
 CxHashKey cx_hash_key(
-        void *obj,
+        void const *obj,
         size_t len
 );
 
--- a/src/hash_key.c	Sun Nov 06 14:17:33 2022 +0100
+++ b/src/hash_key.c	Sun Nov 06 14:46:59 2022 +0100
@@ -96,11 +96,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;
--- a/test/test_hash_key.cpp	Sun Nov 06 14:17:33 2022 +0100
+++ b/test/test_hash_key.cpp	Sun Nov 06 14:46:59 2022 +0100
@@ -37,7 +37,8 @@
     auto str_key = cx_hash_key_str(str);
     auto bytes_key = cx_hash_key_bytes(
             reinterpret_cast<unsigned char const *>(str), len);
-    auto obj_key = cx_hash_key((void *) str, len);
+    auto obj_key = cx_hash_key(
+            reinterpret_cast<void const *>(str), len);
 
     EXPECT_EQ(str_key.hash, bytes_key.hash);
     EXPECT_EQ(obj_key.hash, bytes_key.hash);

mercurial