From: Aki Tuomi Date: Wed, 12 Feb 2020 08:45:35 +0000 (+0200) Subject: lib: hash2 - Add string key helpers X-Git-Tag: 2.3.11.2~595 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e90f906024ef3dc002be3b13797cf871ebf35dc2;p=thirdparty%2Fdovecot%2Fcore.git lib: hash2 - Add string key helpers --- diff --git a/src/lib/hash2.h b/src/lib/hash2.h index bdd1b53d80..d7febe612f 100644 --- a/src/lib/hash2.h +++ b/src/lib/hash2.h @@ -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