[MEDIUM] ebtree: upgrade to version 6.0
This version adds support for prefix-based matching of memory blocks,
as well as some code-size and performance improvements on the generic
code. It provides a prefix insertion and longest match which are
compatible with the rest of the common features (walk, duplicates,
delete, ...). This is typically used for network address matching. The
longest-match code is a bit slower than the original memory block
handling code, so they have not been merged together into generic
code. Still it's possible to perform about 10 million networks lookups
per second in a set of 50000, so this should be enough for most usages.
This version also fixes some bugs in parts that were not used, so there
is no need to backport them.
diff --git a/ebtree/ebpttree.c b/ebtree/ebpttree.c
index 76e6db8..d0ca15f 100644
--- a/ebtree/ebpttree.c
+++ b/ebtree/ebpttree.c
@@ -1,6 +1,7 @@
/*
* Elastic Binary Trees - exported functions for operations on pointer nodes.
- * (C) 2002-2007 - Willy Tarreau <w@1wt.eu>
+ * Version 6.0
+ * (C) 2002-2010 - Willy Tarreau <w@1wt.eu>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -87,7 +88,7 @@
* small and we need to get its highest value, or it is
* too large, and we need to get the prev value.
*/
- if (((ptr_t)node->key >> node->node.bit) > ((ptr_t)x >> node->node.bit)) {
+ if (((ptr_t)node->key >> node->node.bit) < ((ptr_t)x >> node->node.bit)) {
troot = node->node.branches.b[EB_RGHT];
return ebpt_entry(eb_walk_down(troot, EB_RGHT), struct ebpt_node, node);
}