Changeset a35b458 in mainline for kernel/generic/src/adt/avl.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/adt/avl.c

    r3061bc1 ra35b458  
    6666{
    6767        avltree_node_t *p;
    68        
     68
    6969        /*
    7070         * Iteratively descend to the leaf that can contain the searched key.
     
    9292{
    9393        avltree_node_t *p = t->root;
    94        
     94
    9595        /*
    9696         * Check whether the tree is empty.
     
    9898        if (!p)
    9999                return NULL;
    100        
     100
    101101        /*
    102102         * Iteratively descend to the leftmost leaf in the tree.
     
    104104        while (p->lft != NULL)
    105105                p = p->lft;
    106        
     106
    107107        return p;
    108108}
     
    151151#define REBALANCE_INSERT_LR()           REBALANCE_INSERT_XY(lft, rgt, 1)
    152152#define REBALANCE_INSERT_RL()           REBALANCE_INSERT_XY(rgt, lft, -1)
    153        
     153
    154154/** Insert new node into AVL tree.
    155155 *
     
    172172         */
    173173        key = newnode->key + t->base;
    174        
     174
    175175        /*
    176176         * Iteratively descend to the leaf that can contain the new node.
     
    244244                }
    245245        }
    246        
     246
    247247        /*
    248248         * To balance the tree, we must check and balance top node.
     
    260260                         */
    261261                        assert(par->balance == 1);
    262                        
     262
    263263                        REBALANCE_INSERT_LR();
    264264                }
     
    275275                         */
    276276                        assert(par->balance == -1);
    277                
     277
    278278                        REBALANCE_INSERT_RL();
    279279                }
     
    375375        assert(t);
    376376        assert(node);
    377        
     377
    378378        if (node->lft == NULL) {
    379379                if (node->rgt) {
     
    451451                cur->par = node->par;
    452452        }
    453        
     453
    454454        /*
    455455         * Repair the parent node's pointer which pointed previously to the
     
    457457         */
    458458        (void) repair(t, node, node, cur, NULL, false);
    459        
     459
    460460        /*
    461461         * Repair cycle which repairs balances of nodes on the way from from the
     
    484484                                         * RL rotation.
    485485                                         */
    486                                        
     486
    487487                                        cur = par->lft;
    488488                                        par->lft = cur->rgt;
     
    490490                                        gpa->rgt = cur->lft;
    491491                                        cur->lft = gpa;
    492                                        
     492
    493493                                        /*
    494494                                         * Repair balances and paternity of
     
    497497                                         */
    498498                                        REBALANCE_DELETE_RL();
    499                                        
     499
    500500                                        /*
    501501                                         * Repair paternity.
     
    513513                                         * RR rotation.
    514514                                         */
    515                                        
     515
    516516                                        gpa->rgt = par->lft;
    517517                                        if (par->lft)
    518518                                                par->lft->par = gpa;
    519519                                        par->lft = gpa;
    520                                        
     520
    521521                                        /*
    522522                                         * Repair paternity.
     
    524524                                        par->par = gpa->par;
    525525                                        gpa->par = par;
    526                                        
     526
    527527                                        if (par->balance == 0) {
    528528                                                /*
     
    575575                                 */
    576576                                par = gpa->lft;
    577                                
     577
    578578                                if (par->balance == 1) {
    579579                                        /*
    580580                                         * LR rotation.
    581581                                         */
    582                                        
     582
    583583                                        cur = par->rgt;
    584584                                        par->rgt = cur->lft;
     
    586586                                        gpa->lft = cur->rgt;
    587587                                        cur->rgt = gpa;
    588                                        
     588
    589589                                        /*
    590590                                         * Repair balances and paternity of
     
    619619                                        par->par = gpa->par;
    620620                                        gpa->par = par;
    621                                        
     621
    622622                                        if (par->balance == 0) {
    623623                                                /*
     
    630630                                                par->balance = 1;
    631631                                                gpa->balance = -1;
    632                                                
     632
    633633                                                (void) repair(t, par, gpa, par,
    634634                                                    NULL, false);
     
    637637                                                par->balance = 0;
    638638                                                gpa->balance = 0;
    639                                                
     639
    640640                                                if (!repair(t, par, gpa, par,
    641641                                                    &dir, false))
     
    667667{
    668668        avltree_node_t *node;
    669        
     669
    670670        /*
    671671         * Start searching for the smallest key in the tree starting in the root
     
    673673         * must have the smallest key).
    674674         */
    675          
     675
    676676        node = t->root;
    677677        if (!node)
    678678                return false;
    679        
     679
    680680        while (node->lft != NULL)
    681681                node = node->lft;
    682        
     682
    683683        avltree_delete(t, node);
    684684
Note: See TracChangeset for help on using the changeset viewer.