Changeset 55b77d9 in mainline for kernel/generic/src/adt/hash_table.c


Ignore:
Timestamp:
2011-06-17T20:39:16Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8f164724
Parents:
98caf49
Message:

Separate list_t typedef from link_t (kernel part).

  • list_t represents lists
  • Use list_first(), list_last(), list_empty() where appropriate
  • Use list_foreach() where possible
  • Replace improper uses of list_prepend() with list_insert_after()
  • Replace improper uses of list_append() with list_insert_before()
File:
1 edited

Legend:

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

    r98caf49 r55b77d9  
    6262        ASSERT(max_keys > 0);
    6363       
    64         h->entry = (link_t *) malloc(m * sizeof(link_t), 0);
     64        h->entry = (list_t *) malloc(m * sizeof(list_t), 0);
    6565        if (!h->entry)
    6666                panic("Cannot allocate memory for hash table.");
    6767       
    68         memsetb(h->entry, m * sizeof(link_t), 0);
     68        memsetb(h->entry, m * sizeof(list_t), 0);
    6969       
    7070        for (i = 0; i < m; i++)
     
    107107link_t *hash_table_find(hash_table_t *h, sysarg_t key[])
    108108{
    109         link_t *cur;
    110109        size_t chain;
    111110       
     
    118117        ASSERT(chain < h->entries);
    119118       
    120         for (cur = h->entry[chain].next; cur != &h->entry[chain]; cur = cur->next) {
     119        list_foreach(h->entry[chain], cur) {
    121120                if (h->op->compare(key, h->max_keys, cur)) {
    122121                        /*
     
    141140{
    142141        size_t chain;
    143         link_t *cur;
    144142       
    145143        ASSERT(h);
     
    150148       
    151149        if (keys == h->max_keys) {
     150                link_t *cur;
    152151       
    153152                /*
     
    169168         */
    170169        for (chain = 0; chain < h->entries; chain++) {
    171                 for (cur = h->entry[chain].next; cur != &h->entry[chain]; cur = cur->next) {
     170                list_foreach(h->entry[chain], cur) {
    172171                        if (h->op->compare(key, keys, cur)) {
    173172                                link_t *hlp;
Note: See TracChangeset for help on using the changeset viewer.