Ignore:
File:
1 edited

Legend:

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

    rb72efe8 re1da7ec  
    5454 *
    5555 */
    56 bool hash_table_create(hash_table_t *h, hash_count_t m, hash_count_t max_keys,
     56int hash_table_create(hash_table_t *h, hash_count_t m, hash_count_t max_keys,
    5757    hash_table_operations_t *op)
    5858{
     
    6161        assert(max_keys > 0);
    6262       
    63         h->entry = malloc(m * sizeof(list_t));
     63        h->entry = malloc(m * sizeof(link_t));
    6464        if (!h->entry)
    6565                return false;
    6666       
    67         memset((void *) h->entry, 0,  m * sizeof(list_t));
     67        memset((void *) h->entry, 0,  m * sizeof(link_t));
    6868       
    6969        hash_count_t i;
     
    123123        assert(chain < h->entries);
    124124       
    125         list_foreach(h->entry[chain], cur) {
     125        link_t *cur;
     126        for (cur = h->entry[chain].next; cur != &h->entry[chain];
     127            cur = cur->next) {
    126128                if (h->op->compare(key, h->max_keys, cur)) {
    127129                        /*
     
    151153        assert(keys <= h->max_keys);
    152154       
     155        link_t *cur;
     156       
    153157        if (keys == h->max_keys) {
    154                 link_t *cur;
    155                
    156158                /*
    157159                 * All keys are known, hash_table_find() can be used to find the
     
    174176        hash_index_t chain;
    175177        for (chain = 0; chain < h->entries; chain++) {
    176                 link_t *cur;
    177                
    178                 for (cur = h->entry[chain].head.next; cur != &h->entry[chain].head;
     178                for (cur = h->entry[chain].next; cur != &h->entry[chain];
    179179                    cur = cur->next) {
    180180                        if (h->op->compare(key, keys, cur)) {
     
    203203{
    204204        hash_index_t bucket;
     205        link_t *cur;
    205206       
    206207        for (bucket = 0; bucket < h->entries; bucket++) {
    207                 list_foreach(h->entry[bucket], cur) {
     208                for (cur = h->entry[bucket].next; cur != &h->entry[bucket];
     209                    cur = cur->next) {
    208210                        f(cur, arg);
    209211                }
Note: See TracChangeset for help on using the changeset viewer.