aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/radix.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-13 14:32:53 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-02-13 14:32:53 +0000
commit2ba49f78f545af9e6e0057da5db4073e7f91a29f (patch)
tree6fd9271df7a9c89a1dbb7818aee12020cf641fa3 /src/libutil/radix.c
parent5e311513d90b0ff1501607f18b547d2e2db053a2 (diff)
downloadrspamd-2ba49f78f545af9e6e0057da5db4073e7f91a29f.tar.gz
rspamd-2ba49f78f545af9e6e0057da5db4073e7f91a29f.zip
Add diagnostic for new radix
Diffstat (limited to 'src/libutil/radix.c')
-rw-r--r--src/libutil/radix.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/libutil/radix.c b/src/libutil/radix.c
index 2b67d7917..a8bf5e3d3 100644
--- a/src/libutil/radix.c
+++ b/src/libutil/radix.c
@@ -67,18 +67,27 @@ radix_insert_compressed (radix_compressed_t * tree,
{
guint keybits = keylen * NBBY;
uintptr_t old;
+ int ret;
g_assert (tree != NULL);
g_assert (keybits >= masklen);
msg_debug_radix ("want insert value %p with mask %z, key: %*xs",
- (gpointer)value, masklen, (int)keybits, key);
+ (gpointer)value, keybits - masklen, (int)keylen, key);
old = radix_find_compressed (tree, key, keylen);
- btrie_add_prefix (tree->tree, key, keybits - masklen,
+ ret = btrie_add_prefix (tree->tree, key, keybits - masklen,
(gconstpointer)value);
+ if (ret != BTRIE_OKAY) {
+ msg_err_radix ("cannot insert %p with mask %z, key: %*xs, duplicate value",
+ (gpointer)value, keybits - masklen, (int)keylen, key);
+ }
+ else {
+ tree->size ++;
+ }
+
return old;
}