Changeset 8565a42 in mainline for uspace/lib/c/generic/adt


Ignore:
Timestamp:
2018-03-02T20:34:50Z (8 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

Location:
uspace/lib/c/generic/adt
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/adt/checksum.c

    r3061bc1 r8565a42  
    136136{
    137137        uint32_t crc;
    138        
     138
    139139        for (crc = ~seed; length > 0; length--)
    140140                crc = poly_table[((uint8_t) crc ^ *(data++))] ^ (crc >> 8);
    141        
     141
    142142        return (~crc);
    143143}
  • uspace/lib/c/generic/adt/circ_buf.c

    r3061bc1 r8565a42  
    3030 * @{
    3131 */
    32  
     32
    3333/** @file Circular buffer
    3434 */
  • uspace/lib/c/generic/adt/hash_table.c

    r3061bc1 r8565a42  
    9696        assert(h);
    9797        assert(op && op->hash && op->key_hash && op->key_equal);
    98        
     98
    9999        /* Check for compulsory ops. */
    100100        if (!op || !op->hash || !op->key_hash || !op->key_equal)
    101101                return false;
    102        
     102
    103103        h->bucket_cnt = round_up_size(init_size);
    104        
     104
    105105        if (!alloc_table(h->bucket_cnt, &h->bucket))
    106106                return false;
    107        
     107
    108108        h->max_load = (max_load == 0) ? HT_MAX_LOAD : max_load;
    109109        h->item_cnt = 0;
     
    115115                h->op->remove_callback = nop_remove_callback;
    116116        }
    117        
     117
    118118        return true;
    119119}
     
    128128        assert(h && h->bucket);
    129129        assert(!h->apply_ongoing);
    130        
     130
    131131        clear_items(h);
    132        
     132
    133133        free(h->bucket);
    134134
     
    159159        assert(h && h->bucket);
    160160        assert(!h->apply_ongoing);
    161        
     161
    162162        clear_items(h);
    163        
     163
    164164        /* Shrink the table to its minimum size if possible. */
    165165        if (HT_MIN_BUCKETS < h->bucket_cnt) {
     
    173173        if (h->item_cnt == 0)
    174174                return;
    175        
     175
    176176        for (size_t idx = 0; idx < h->bucket_cnt; ++idx) {
    177177                list_foreach_safe(h->bucket[idx], cur, next) {
    178178                        assert(cur);
    179179                        ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link);
    180                        
     180
    181181                        list_remove(cur);
    182182                        h->op->remove_callback(cur_link);
    183183                }
    184184        }
    185        
     185
    186186        h->item_cnt = 0;
    187187}
     
    197197        assert(h && h->bucket);
    198198        assert(!h->apply_ongoing);
    199        
     199
    200200        size_t idx = h->op->hash(item) % h->bucket_cnt;
    201        
     201
    202202        list_append(&item->link, &h->bucket[idx]);
    203203        ++h->item_cnt;
     
    220220        assert(h->op && h->op->hash && h->op->equal);
    221221        assert(!h->apply_ongoing);
    222        
     222
    223223        size_t idx = h->op->hash(item) % h->bucket_cnt;
    224        
     224
    225225        /* Check for duplicates. */
    226226        list_foreach(h->bucket[idx], link, ht_link_t, cur_link) {
     
    232232                        return false;
    233233        }
    234        
     234
    235235        list_append(&item->link, &h->bucket[idx]);
    236236        ++h->item_cnt;
    237237        grow_if_needed(h);
    238        
     238
    239239        return true;
    240240}
     
    251251{
    252252        assert(h && h->bucket);
    253        
     253
    254254        size_t idx = h->op->key_hash(key) % h->bucket_cnt;
    255255
     
    264264                }
    265265        }
    266        
     266
    267267        return NULL;
    268268}
     
    306306        assert(h && h->bucket);
    307307        assert(!h->apply_ongoing);
    308        
     308
    309309        size_t idx = h->op->key_hash(key) % h->bucket_cnt;
    310310
    311311        size_t removed = 0;
    312        
     312
    313313        list_foreach_safe(h->bucket[idx], cur, next) {
    314314                ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link);
    315                
     315
    316316                if (h->op->key_equal(key, cur_link)) {
    317317                        ++removed;
     
    323323        h->item_cnt -= removed;
    324324        shrink_if_needed(h);
    325        
     325
    326326        return removed;
    327327}
     
    353353        assert(f);
    354354        assert(h && h->bucket);
    355        
     355
    356356        if (h->item_cnt == 0)
    357357                return;
    358        
     358
    359359        h->apply_ongoing = true;
    360        
     360
    361361        for (size_t idx = 0; idx < h->bucket_cnt; ++idx) {
    362362                list_foreach_safe(h->bucket[idx], cur, next) {
     
    372372out:
    373373        h->apply_ongoing = false;
    374        
     374
    375375        shrink_if_needed(h);
    376376        grow_if_needed(h);
     
    381381{
    382382        size_t rounded_size = HT_MIN_BUCKETS;
    383        
     383
    384384        while (rounded_size < size) {
    385385                rounded_size = 2 * rounded_size + 1;
    386386        }
    387        
     387
    388388        return rounded_size;
    389389}
     
    393393{
    394394        assert(pbuckets && HT_MIN_BUCKETS <= bucket_cnt);
    395                
     395
    396396        list_t *buckets = malloc(bucket_cnt * sizeof(list_t));
    397397        if (!buckets)
    398398                return false;
    399        
     399
    400400        for (size_t i = 0; i < bucket_cnt; i++)
    401401                list_initialize(&buckets[i]);
     
    435435        assert(h && h->bucket);
    436436        assert(HT_MIN_BUCKETS <= new_bucket_cnt);
    437        
     437
    438438        /* We are traversing the table and resizing would mess up the buckets. */
    439439        if (h->apply_ongoing)
    440440                return;
    441        
     441
    442442        list_t *new_buckets;
    443443
     
    445445        if (!alloc_table(new_bucket_cnt, &new_buckets))
    446446                return;
    447        
     447
    448448        if (0 < h->item_cnt) {
    449449                /* Rehash all the items to the new table. */
     
    458458                }
    459459        }
    460        
     460
    461461        free(h->bucket);
    462462        h->bucket = new_buckets;
  • uspace/lib/c/generic/adt/list.c

    r3061bc1 r8565a42  
    5757        bool found = false;
    5858        link_t *hlp = list->head.next;
    59        
     59
    6060        while (hlp != &list->head) {
    6161                if (hlp == link) {
     
    6565                hlp = hlp->next;
    6666        }
    67        
     67
    6868        return found;
    6969}
     
    8181        if (list_empty(list))
    8282                return;
    83        
     83
    8484        /* Attach list to destination. */
    8585        list->head.next->prev = pos;
    8686        list->head.prev->next = pos->next;
    87        
     87
    8888        /* Link destination list to the added list. */
    8989        pos->next->prev = list->head.prev;
    9090        pos->next = list->head.next;
    91        
     91
    9292        list_initialize(list);
    9393}
     
    103103{
    104104        unsigned long count = 0;
    105        
     105
    106106        link_t *link = list_first(list);
    107107        while (link != NULL) {
     
    109109                link = list_next(link, list);
    110110        }
    111        
     111
    112112        return count;
    113113}
  • uspace/lib/c/generic/adt/odict.c

    r3061bc1 r8565a42  
    3030 * @{
    3131 */
    32  
     32
    3333/** @file Ordered dictionary.
    3434 *
  • uspace/lib/c/generic/adt/prodcons.c

    r3061bc1 r8565a42  
    4747{
    4848        fibril_mutex_lock(&pc->mtx);
    49        
     49
    5050        list_append(item, &pc->list);
    5151        fibril_condvar_signal(&pc->cv);
    52        
     52
    5353        fibril_mutex_unlock(&pc->mtx);
    5454}
     
    5757{
    5858        fibril_mutex_lock(&pc->mtx);
    59        
     59
    6060        while (list_empty(&pc->list))
    6161                fibril_condvar_wait(&pc->cv, &pc->mtx);
    62        
     62
    6363        link_t *head = list_first(&pc->list);
    6464        list_remove(head);
    65        
     65
    6666        fibril_mutex_unlock(&pc->mtx);
    67        
     67
    6868        return head;
    6969}
Note: See TracChangeset for help on using the changeset viewer.