Changeset feeac0d in mainline for uspace/lib/c/generic


Ignore:
Timestamp:
2013-09-10T16:32:35Z (12 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4982d87
Parents:
e8d6ce2
Message:

Simplify use of list_foreach.

Location:
uspace/lib/c/generic
Files:
5 edited

Legend:

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

    re8d6ce2 rfeeac0d  
    227227       
    228228        /* Check for duplicates. */
    229         list_foreach(h->bucket[idx], cur) {
     229        list_foreach(h->bucket[idx], link, ht_link_t, cur_link) {
    230230                /*
    231231                 * We could filter out items using their hashes first, but
    232232                 * calling equal() might very well be just as fast.
    233233                 */
    234                 ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link);
    235234                if (h->op->equal(cur_link, item))
    236235                        return false;
     
    258257        size_t idx = h->op->key_hash(key) % h->bucket_cnt;
    259258
    260         list_foreach(h->bucket[idx], cur) {
    261                 ht_link_t *cur_link = member_to_inst(cur, ht_link_t, link);
     259        list_foreach(h->bucket[idx], link, ht_link_t, cur_link) {
    262260                /*
    263261                 * Is this is the item we are looking for? We could have first
  • uspace/lib/c/generic/adt/list.c

    re8d6ce2 rfeeac0d  
    102102        unsigned int count = 0;
    103103       
    104         list_foreach(*list, link) {
     104        link_t *link = list_first(list);
     105        while (link != NULL) {
    105106                count++;
     107                link = list_next(link, list);
    106108        }
    107109       
  • uspace/lib/c/generic/cfg.c

    re8d6ce2 rfeeac0d  
    8383                return true;
    8484       
    85         list_foreach(data->sections, link) {
    86                 const cfg_section_t *section = cfg_section_instance(link);
    87                
     85        cfg_file_foreach(data, section) {
    8886                if (!list_empty(&section->entries))
    8987                        return false;
     
    413411const cfg_section_t *cfg_find_section(const cfg_file_t *data, const char *title)
    414412{
    415         list_foreach(data->sections, link) {
    416                 const cfg_section_t *section = cfg_section_instance(link);
    417                
     413        cfg_file_foreach(data, section) {
    418414                if (str_cmp(section->title, title) == 0)
    419415                        return section;
     
    434430const char *cfg_find_value(const cfg_section_t *section, const char *key)
    435431{
    436         list_foreach(section->entries, link) {
    437                 const cfg_entry_t *entry = cfg_entry_instance(link);
    438                
     432        cfg_section_foreach(section, entry) {
    439433                if (str_cmp(entry->key, key) == 0)
    440434                        return entry->value;
  • uspace/lib/c/generic/devman.c

    re8d6ce2 rfeeac0d  
    230230        }
    231231       
    232         match_id_t *match_id = NULL;
    233        
    234         list_foreach(match_ids->ids, link) {
    235                 match_id = list_get_instance(link, match_id_t, link);
    236                
     232        list_foreach(match_ids->ids, link, match_id_t, match_id) {
    237233                ipc_call_t answer2;
    238234                aid_t req2 = async_send_1(exch, DEVMAN_ADD_MATCH_ID,
  • uspace/lib/c/generic/pio_trace.c

    re8d6ce2 rfeeac0d  
    9595        pio_regions_t *regions = get_regions();
    9696        fibril_rwlock_read_lock(&regions->guard);
    97         list_foreach(regions->list, it) {
    98                 assert(it);
    99                 region_t *reg = region_instance(it);
    100                 assert(reg);
     97        list_foreach(regions->list, link, region_t, reg) {
    10198                if ((r >= reg->base) && (r < reg->base + reg->size)) {
    10299                        if (reg->log)
     
    131128        fibril_rwlock_write_lock(&regions->guard);
    132129        list_foreach_safe(regions->list, it, next) {
    133                 assert(it);
    134130                region_t *reg = region_instance(it);
    135                 assert(reg);
    136131                if (r >= reg->base && (r < reg->base + reg->size)) {
    137                                 list_remove(&reg->link);
    138                                 region_destroy(reg);
     132                        list_remove(&reg->link);
     133                        region_destroy(reg);
    139134                }
    140135        }
Note: See TracChangeset for help on using the changeset viewer.