Rev 2421 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2421 | Rev 2431 | ||
---|---|---|---|
Line 161... | Line 161... | ||
161 | newnode->lft_height = 0; |
161 | newnode->lft_height = 0; |
162 | newnode->rgt_height = 0; |
162 | newnode->rgt_height = 0; |
163 | newnode->par = cur; |
163 | newnode->par = cur; |
164 | 164 | ||
165 | gpa = cur; |
165 | gpa = cur; |
166 | while (gpa != &t->head && gpa->key == cur->key) |
166 | while ((gpa != &t->head) && (gpa->key == cur->key)) |
167 | gpa = gpa->prev; |
167 | gpa = gpa->prev; |
168 | newnode->next = gpa->next; |
168 | newnode->next = gpa->next; |
169 | newnode->prev = gpa; |
169 | newnode->prev = gpa; |
170 | gpa->next->prev = newnode; |
170 | gpa->next->prev = newnode; |
171 | gpa->next = newnode; |
171 | gpa->next = newnode; |
Line 401... | Line 401... | ||
401 | gpapar = &(node->par->rgt); |
401 | gpapar = &(node->par->rgt); |
402 | } |
402 | } |
403 | } |
403 | } |
404 | 404 | ||
405 | 405 | ||
406 | if (&t->head != node->prev && node->prev->key == node->key) { |
406 | if ((&t->head != node->prev) && (node->prev->key == node->key)) { |
407 | /* |
407 | /* |
408 | * Deleted node has at least one node node with the same key which is closest previous |
408 | * Deleted node has at least one node node with the same key which is closest previous |
409 | * neighbor in the list, copy node atributes into previous node and end. |
409 | * neighbor in the list, copy node atributes into previous node and end. |
410 | */ |
410 | */ |
411 | cur = node->prev; |
411 | cur = node->prev; |
Line 745... | Line 745... | ||
745 | */ |
745 | */ |
746 | 746 | ||
747 | expnode->par->lft = NULL; |
747 | expnode->par->lft = NULL; |
748 | expnode->par->lft_height = 0; |
748 | expnode->par->lft_height = 0; |
749 | } |
749 | } |
- | 750 | } else if (expnode->next == &t->head) { |
|
- | 751 | /* |
|
- | 752 | * Special case of deleting last node with key equal 0. |
|
- | 753 | */ |
|
- | 754 | t->root = NULL; |
|
750 | } |
755 | } |
751 | 756 | ||
752 | /* |
757 | /* |
753 | * Delete node from the list. |
758 | * Delete node from the list. |
754 | */ |
759 | */ |