* to the project. For more information see the website or contact
* the copyright holders.
*
- * $Id: lq_avl.c,v 1.16 2007/11/16 22:56:54 bernd67 Exp $
+ * $Id: lq_avl.c,v 1.17 2007/11/18 20:35:59 bernd67 Exp $
*/
#include <stddef.h>
#include <string.h>
#include "lq_avl.h"
-
-#define AVLMAX(x, y) ((x > y) ? x : y)
-#define AVLMIN(x, y) ((x < y) ? x : y)
+#include "net_olsr.h"
/*
* default comparison pointers
int avl_comp_ipv4(const void *ip1, const void *ip2)
{
- return inline_avl_comp_ipv4(ip1, ip2);
+ return ip4cmp(ip1, ip2);
}
int avl_comp_ipv6(const void *ip1, const void *ip2)
{
- return memcmp(ip1, ip2, 16);
+ return ip6cmp(ip1, ip2);
}
void avl_init(struct avl_tree *tree, avl_tree_comp comp)
if (NULL == tree->comp)
{
- if (0 != inline_avl_comp_ipv4(node->key, key))
+ if (0 != ip4cmp(node->key, key))
return NULL;
}
if (node->left != NULL)
node->left->parent = node;
- node->balance += 1 - AVLMIN(left->balance, 0);
- left->balance += 1 + AVLMAX(node->balance, 0);
+ node->balance += 1 - MIN(left->balance, 0);
+ left->balance += 1 + MAX(node->balance, 0);
}
static void avl_rotate_left(struct avl_tree *tree, struct avl_node *node)
if (node->right != NULL)
node->right->parent = node;
- node->balance -= 1 + AVLMAX(right->balance, 0);
- right->balance -= 1 - AVLMIN(node->balance, 0);
+ node->balance -= 1 + MAX(right->balance, 0);
+ right->balance -= 1 - MIN(node->balance, 0);
}
static void post_insert(struct avl_tree *tree, struct avl_node *node)
last = last->next;
if (NULL == tree->comp)
- diff = inline_avl_comp_ipv4(new->key, node->key);
+ diff = ip4cmp(new->key, node->key);
else
diff = (*tree->comp)(new->key, node->key);
* to the project. For more information see the website or contact
* the copyright holders.
*
- * $Id: lq_avl.h,v 1.13 2007/11/11 22:55:16 bernd67 Exp $
+ * $Id: lq_avl.h,v 1.14 2007/11/18 20:35:59 bernd67 Exp $
*/
#ifndef _LQ_AVL_H
extern int avl_comp_ipv4(const void *, const void *);
extern int avl_comp_ipv6(const void *, const void *);
-static INLINE int inline_avl_comp_ipv4(const void *_ip1, const void *_ip2) {
- const unsigned int *ip1 = _ip1, *ip2 = _ip2;
- return *ip1 == *ip2 ? 0 : *ip1 < *ip2 ? -1 : +1; }
-
#endif
/*