[Olsr-cvs] olsrd-current/src lq_avl.c, 1.16, 1.17 lq_avl.h, 1.13, 1.14

Bernd Petrovitsch (spam-protected)
Sun Nov 18 21:36:01 CET 2007


Update of /cvsroot/olsrd/olsrd-current/src
In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv25945/src

Modified Files:
	lq_avl.c lq_avl.h 
Log Message:
- use ip{4,}cmp in lq_avl.[ch] to resue the code. inline_avl_comp_ipv4
  is superflous now (and replaced by ip4cmp).
- use the global MIN and MAX macro instead of AVLMIN and AVLMAX


Index: lq_avl.h
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_avl.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** lq_avl.h	11 Nov 2007 22:55:16 -0000	1.13
--- lq_avl.h	18 Nov 2007 20:35:59 -0000	1.14
***************
*** 93,100 ****
  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
  
--- 93,96 ----

Index: lq_avl.c
===================================================================
RCS file: /cvsroot/olsrd/olsrd-current/src/lq_avl.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** lq_avl.c	16 Nov 2007 22:56:54 -0000	1.16
--- lq_avl.c	18 Nov 2007 20:35:59 -0000	1.17
***************
*** 46,52 ****
  
  #include "lq_avl.h"
! 
! #define AVLMAX(x, y) ((x > y) ? x : y)
! #define AVLMIN(x, y) ((x < y) ? x : y)
  
  /*
--- 46,50 ----
  
  #include "lq_avl.h"
! #include "net_olsr.h"
  
  /*
***************
*** 61,70 ****
  int avl_comp_ipv4(const void *ip1, const void *ip2)
  {
!   return inline_avl_comp_ipv4(ip1, ip2);
  }
  
  int avl_comp_ipv6(const void *ip1, const void *ip2)
  {
!   return memcmp(ip1, ip2, 16);
  }
  
--- 59,68 ----
  int avl_comp_ipv4(const void *ip1, const void *ip2)
  {
!   return ip4cmp(ip1, ip2);
  }
  
  int avl_comp_ipv6(const void *ip1, const void *ip2)
  {
!   return ip6cmp(ip1, ip2);
  }
  
***************
*** 135,139 ****
    if (NULL == tree->comp)
    {
!     if (0 != inline_avl_comp_ipv4(node->key, key))
        return NULL;
    }
--- 133,137 ----
    if (NULL == tree->comp)
    {
!     if (0 != ip4cmp(node->key, key))
        return NULL;
    }
***************
*** 176,181 ****
      node->left->parent = node;
  
!   node->balance += 1 - AVLMIN(left->balance, 0);
!   left->balance += 1 + AVLMAX(node->balance, 0);
  }
  
--- 174,179 ----
      node->left->parent = node;
  
!   node->balance += 1 - MIN(left->balance, 0);
!   left->balance += 1 + MAX(node->balance, 0);
  }
  
***************
*** 208,213 ****
      node->right->parent = node;
  
!   node->balance -= 1 + AVLMAX(right->balance, 0);
!   right->balance -= 1 - AVLMIN(node->balance, 0);
  }
  
--- 206,211 ----
      node->right->parent = node;
  
!   node->balance -= 1 + MAX(right->balance, 0);
!   right->balance -= 1 - MIN(node->balance, 0);
  }
  
***************
*** 345,349 ****
  
    if (NULL == tree->comp)
!     diff = inline_avl_comp_ipv4(new->key, node->key);
  
    else
--- 343,347 ----
  
    if (NULL == tree->comp)
!     diff = ip4cmp(new->key, node->key);
  
    else





More information about the Olsr-cvs mailing list