]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: hash2 - Add string key helpers
authorAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2020 08:45:35 +0000 (10:45 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Thu, 20 Feb 2020 11:19:56 +0000 (11:19 +0000)
src/lib/hash2.h

index bdd1b53d808f44e48eee6b4378900734a784b1af..d7febe612ff2a05eb01c883e2a56e423a83d11dd 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef HASH2_H
 #define HASH2_H
 
+#include "hash.h"
+
 struct hash2_iter {
        struct hash2_value *value, *next_value;
        unsigned int key_hash;
@@ -40,4 +42,15 @@ void hash2_remove_iter(struct hash2_table *hash, struct hash2_iter *iter);
 /* Return the number of nodes in hash table. */
 unsigned int hash2_count(const struct hash2_table *hash) ATTR_PURE;
 
+/* can be used with string keys */
+static inline bool hash2_strcmp(const void *a, const void *b, void *ctx ATTR_UNUSED)
+{
+       return strcmp(a, b) == 0;
+}
+
+static inline unsigned int hash2_str_hash(const void *key)
+{
+       return str_hash(key);
+}
+
 #endif