]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
util: introduce two trivial hash_ops
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 13 Oct 2020 13:40:19 +0000 (22:40 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 13 Oct 2020 13:40:22 +0000 (22:40 +0900)
Will be used in a later commit.

src/basic/hash-funcs.c
src/basic/hash-funcs.h

index cf279e5cbefc5673d66ca7369084d4682a12ff64..83016c0fd616ad74047a24b41abe2c08ffcb0bf8 100644 (file)
@@ -71,6 +71,19 @@ const struct hash_ops trivial_hash_ops = {
         .compare = trivial_compare_func,
 };
 
+const struct hash_ops trivial_hash_ops_free = {
+        .hash = trivial_hash_func,
+        .compare = trivial_compare_func,
+        .free_key = free,
+};
+
+const struct hash_ops trivial_hash_ops_free_free = {
+        .hash = trivial_hash_func,
+        .compare = trivial_compare_func,
+        .free_key = free,
+        .free_value = free,
+};
+
 void uint64_hash_func(const uint64_t *p, struct siphash *state) {
         siphash24_compress(p, sizeof(uint64_t), state);
 }
index 005d1b21d21ea0806ccda6f66ccaf104edc2369d..fb602009416ea10f3e24a5fa08b2a67b49c3d489 100644 (file)
@@ -88,6 +88,8 @@ extern const struct hash_ops path_hash_ops_free;
 void trivial_hash_func(const void *p, struct siphash *state);
 int trivial_compare_func(const void *a, const void *b) _const_;
 extern const struct hash_ops trivial_hash_ops;
+extern const struct hash_ops trivial_hash_ops_free;
+extern const struct hash_ops trivial_hash_ops_free_free;
 
 /* 32bit values we can always just embed in the pointer itself, but in order to support 32bit archs we need store 64bit
  * values indirectly, since they don't fit in a pointer. */