Changeset f959a20f in mainline for uspace/lib/c


Ignore:
Timestamp:
2019-02-01T22:32:38Z (6 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
00b7fc8
Parents:
1a37496
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-01 21:22:39)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2019-02-01 22:32:38)
Message:

Avoid directly using .head/.next/.prev of list_t/link_t

Use existing constructs from <adt/list.h> instead.

Location:
uspace/lib/c
Files:
3 edited

Legend:

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

    r1a37496 rf959a20f  
    273273
    274274        size_t idx = h->op->hash(item) % h->bucket_cnt;
     275        list_t *list = &h->bucket[idx];
    275276
    276277        /* Traverse the circular list until we reach the starting item again. */
    277         for (link_t *cur = item->link.next; cur != &first->link;
    278             cur = cur->next) {
    279                 assert(cur);
    280 
    281                 if (cur == &h->bucket[idx].head)
    282                         continue;
     278        for (link_t *cur = list_next(&item->link, list); cur != &first->link;
     279            cur = list_next(cur, list)) {
     280
     281                if (!cur)
     282                        cur = list_first(list);
    283283
    284284                ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link);
  • uspace/lib/c/generic/thread/fibril.c

    r1a37496 rf959a20f  
    601601        assert(timeout);
    602602
    603         link_t *tmp = timeout_list.head.next;
    604         while (tmp != &timeout_list.head) {
    605                 _timeout_t *cur = list_get_instance(tmp, _timeout_t, link);
    606 
    607                 if (ts_gteq(&cur->expires, &timeout->expires))
    608                         break;
    609 
    610                 tmp = tmp->next;
    611         }
    612 
    613         list_insert_before(&timeout->link, tmp);
     603        list_foreach(timeout_list, link, _timeout_t, cur) {
     604                if (ts_gteq(&cur->expires, &timeout->expires)) {
     605                        list_insert_before(&timeout->link, &cur->link);
     606                        return;
     607                }
     608        }
     609
     610        list_append(&timeout->link, &timeout_list);
    614611}
    615612
  • uspace/lib/c/include/ipc/devman.h

    r1a37496 rf959a20f  
    108108static inline void add_match_id(match_id_list_t *ids, match_id_t *id)
    109109{
    110         match_id_t *mid = NULL;
    111         link_t *link = ids->ids.head.next;
    112 
    113         while (link != &ids->ids.head) {
    114                 mid = list_get_instance(link, match_id_t, link);
     110        list_foreach(ids->ids, link, match_id_t, mid) {
    115111                if (mid->score < id->score) {
    116                         break;
     112                        list_insert_before(&id->link, &mid->link);
     113                        return;
    117114                }
    118                 link = link->next;
    119115        }
    120116
    121         list_insert_before(&id->link, link);
     117        list_append(&id->link, &ids->ids);
    122118}
    123119
Note: See TracChangeset for help on using the changeset viewer.