aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-04-05 16:13:41 +0100
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-04-05 16:13:41 +0100
commitdb7f8d68e4fa77df5e09d94b7bb6587deb838852 (patch)
treec68313addf4cf2a165b964757e540634d0ae4d76 /src
parent9771c1043772d15388920c5e0dcb82fb7890b451 (diff)
downloadrspamd-db7f8d68e4fa77df5e09d94b7bb6587deb838852.tar.gz
rspamd-db7f8d68e4fa77df5e09d94b7bb6587deb838852.zip
[Minor] Add methods to get LRU hash sizes
Diffstat (limited to 'src')
-rw-r--r--src/libutil/hash.c17
-rw-r--r--src/libutil/hash.h12
2 files changed, 29 insertions, 0 deletions
diff --git a/src/libutil/hash.c b/src/libutil/hash.c
index b42dc6c51..d4fdfea46 100644
--- a/src/libutil/hash.c
+++ b/src/libutil/hash.c
@@ -697,4 +697,21 @@ rspamd_lru_hash_foreach (rspamd_lru_hash_t *h, int it, gpointer *k,
}
return i;
+}
+
+
+guint
+rspamd_lru_hash_size (rspamd_lru_hash_t *hash)
+{
+ return kh_size (hash);
+}
+
+/**
+ * Returns hash capacity
+ * @param hash hash object
+ */
+guint
+rspamd_lru_hash_capacity (rspamd_lru_hash_t *hash)
+{
+ return hash->n_buckets;
} \ No newline at end of file
diff --git a/src/libutil/hash.h b/src/libutil/hash.h
index f983a0be8..bae3cacfa 100644
--- a/src/libutil/hash.h
+++ b/src/libutil/hash.h
@@ -89,4 +89,16 @@ void rspamd_lru_hash_destroy (rspamd_lru_hash_t *hash);
*/
int rspamd_lru_hash_foreach (rspamd_lru_hash_t *hash, int it, gpointer *k,
gpointer *v);
+
+/**
+ * Returns number of elements in a hash
+ * @param hash hash object
+ */
+guint rspamd_lru_hash_size (rspamd_lru_hash_t *hash);
+
+/**
+ * Returns hash capacity
+ * @param hash hash object
+ */
+guint rspamd_lru_hash_capacity (rspamd_lru_hash_t *hash);
#endif