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


Ignore:
Timestamp:
2011-07-08T17:01:01Z (13 years ago)
Author:
Martin Sucha <sucha14@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cc1a727
Parents:
4e36219 (diff), 026793d (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.
Message:

Merge mainline changes

File:
1 edited

Legend:

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

    r4e36219 rc028b22  
    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);
     
    149147        ASSERT(keys <= h->max_keys);
    150148       
     149       
    151150        if (keys == h->max_keys) {
    152        
     151                link_t *cur;
     152               
    153153                /*
    154154                 * All keys are known, hash_table_find() can be used to find the entry.
     
    169169         */
    170170        for (chain = 0; chain < h->entries; chain++) {
    171                 for (cur = h->entry[chain].next; cur != &h->entry[chain]; cur = cur->next) {
     171                link_t *cur;
     172                for (cur = h->entry[chain].head.next; cur != &h->entry[chain].head;
     173                    cur = cur->next) {
    172174                        if (h->op->compare(key, keys, cur)) {
    173175                                link_t *hlp;
Note: See TracChangeset for help on using the changeset viewer.