aboutsummaryrefslogtreecommitdiffstats
path: root/src/libutil/radix.c
diff options
context:
space:
mode:
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;
}