Dear VIS Developers,
I used AVL package from GLU-1.4 in a project of my own. It compiled
correctly but the program kept having runtime problems. I traced down
the reason of the crashes to the function avl_find_or_add(), which can
be found in ".../glu-1.4/src/avl/avl.c"
This function had several bugs, which I corrected. As a result, my
project started to work. The reason why this function had bugs on the
first place is that it is not used anywhere in the SIS or VIS code. From
the kind of bugs it had it is reasonable to assume that it was not
properly tested since the development time.
The orginal code:
-----------------
int
avl_find_or_add(tree, key, slot_p)
avl_tree *tree;
char *key;
char ***slot_p;
{
...
/* insert the item and re-balance the tree */ - line 1
*node_p = new_node(key, NIL(char)); - line 2
do_rebalance(stack_nodep, stack_n); - line 3
tree->num_entries++; - line 4
tree->modified = 1; - line 5
if (slot_p != 0) *slot_p = &node->value; - line 6
return 0; - line 7
}
The problems:
------------
Line 6: 'node' is not initialized
SOLUTION: replace 'node' by '(*node_p)'
Line 6: an attempt is made to save the address of the new slot after
calling do_rebalance(), which modifies it
SOLUTION: change the order of lines, so that the assignment proceeded
the call to do_rebalance()
The corrected version of the code:
-------------------------------
/* insert the item and re-balance the tree */
*node_p = new_node (key, NIL (char));
if (slot_p != 0) *slot_p = &(*node_p)->value;
do_rebalance (stack_nodep, stack_n);
tree->num_entries++;
tree->modified = 1;
return 0;
I have used the modified code in my project. It worked without crashes
and produced correct results.
Regards,
Alan
> Please send bug reports to vis-users@colorado.edu
This archive was generated by hypermail 2b30 : Tue Jun 05 2001 - 18:10:03 MDT