From 2d94c35b631d5d74bba56037a406bb125181e623 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Wed, 13 May 2015 14:03:46 +0100 Subject: Add routine to check radix trie size. --- src/libutil/radix.c | 10 ++++++++++ src/libutil/radix.h | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/src/libutil/radix.c b/src/libutil/radix.c index 605d86668..3ca4c8716 100644 --- a/src/libutil/radix.c +++ b/src/libutil/radix.c @@ -642,6 +642,16 @@ radix_add_generic_iplist (const gchar *ip_list, radix_compressed_t **tree) return (rspamd_radix_add_iplist (ip_list, ",; ", *tree) > 0); } + +gsize +radix_get_size (radix_compressed_t *tree) +{ + if (tree != NULL) { + return tree->size; + } + + return 0; +} /* * vi:ts=4 */ diff --git a/src/libutil/radix.h b/src/libutil/radix.h index 84d617305..a7ea7f868 100644 --- a/src/libutil/radix.h +++ b/src/libutil/radix.h @@ -97,4 +97,11 @@ gint rspamd_radix_add_iplist (const gchar *list, const gchar *separators, gboolean radix_add_generic_iplist (const gchar *ip_list, radix_compressed_t **tree); +/** + * Returns number of elements in the tree + * @param tree + * @return + */ +gsize radix_get_size (radix_compressed_t *tree); + #endif -- cgit v1.2.3