diff options
Diffstat (limited to 'WWW/Library/Implementation/HTBTree.c')
-rw-r--r-- | WWW/Library/Implementation/HTBTree.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/WWW/Library/Implementation/HTBTree.c b/WWW/Library/Implementation/HTBTree.c index 81be0abc..0c172ac4 100644 --- a/WWW/Library/Implementation/HTBTree.c +++ b/WWW/Library/Implementation/HTBTree.c @@ -178,14 +178,16 @@ void HTBTree_add(HTBTree *tree, added_element->right_depth = 0; } } else { /* res >= 0 */ - if (father_of_element->right != NULL) + if (father_of_element->right != NULL) { father_of_element = father_of_element->right; - else { + } else { father_found = NO; father_of_element->right = typeMalloc(HTBTElement); if (father_of_element->right == NULL) outofmem(__FILE__, "HTBTree_add"); + assert(father_of_element->right != NULL); + added_element = father_of_element->right; added_element->up = father_of_element; added_element->object = object; @@ -254,13 +256,15 @@ void HTBTree_add(HTBTree *tree, && (father_of_element->right->left->right == NULL)) corrections = 7; - if ((father_of_element->right == NULL) + if ((father_of_element->left != NULL) + && (father_of_element->right == NULL) && (father_of_element->left->left == NULL) && (father_of_element->left->right->right == NULL) && (father_of_element->left->right->left == NULL)) corrections = 7; - if (father_of_element->left_depth > father_of_element->right_depth) { + if ((father_of_element->left != NULL) + && (father_of_element->left_depth > father_of_element->right_depth)) { added_element = father_of_element->left; father_of_element->left_depth = added_element->right_depth; added_element->right_depth = 1 |