Ignore:
Timestamp:
2018-07-05T21:41:23Z (7 years ago)
Author:
Dzejrou <dzejrou@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0fe0f32
Parents:
5608106c
git-author:
Dzejrou <dzejrou@…> (2018-05-14 17:03:57)
git-committer:
Dzejrou <dzejrou@…> (2018-07-05 21:41:23)
Message:

cpp: fixed bugs found by the map tests

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/cpp/include/internal/rbtree.hpp

    r5608106c r21d97e8  
    353353                if (!node)
    354354                    return nullptr;
     355
     356                --size_;
     357
     358                auto succ = node->successor();
    355359                if (auto tmp = node->get_node_for_deletion(); tmp != nullptr)
    356360                {
     
    359363                     * we popped one node from a list of nodes
    360364                     * with equivalent keys and we can delete it
    361                      * and return the original as it is still
    362                      * in place.
     365                     * and return the successor which was the next
     366                     * in the list.
    363367                     */
    364368                    delete tmp;
    365369
    366                     return node;
    367                 }
    368 
    369                 --size_;
    370 
    371                 if (node == root_)
    372                 {
     370                    update_root_(succ); // Incase the first in list was root.
     371                    return succ;
     372                }
     373                else if (node == root_)
     374                { // Only executed if root_ is unique.
     375                    root_ = nullptr;
    373376                    delete node;
    374                     root_ = nullptr;
    375377
    376378                    return nullptr;
    377379                }
    378380
    379                 auto succ = node->successor();
    380381                if (node->left() && node->right())
    381382                {
     
    407408                    else if (node->is_right_child())
    408409                        child->parent()->right(child);
     410                    node->parent(nullptr);
     411                    node->left(nullptr);
     412                    node->right(nullptr);
    409413
    410414                    // Repair if needed.
Note: See TracChangeset for help on using the changeset viewer.