Changes in uspace/lib/c/generic/adt/hash_table.c [b72efe8:e1da7ec] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/adt/hash_table.c
rb72efe8 re1da7ec 54 54 * 55 55 */ 56 boolhash_table_create(hash_table_t *h, hash_count_t m, hash_count_t max_keys,56 int hash_table_create(hash_table_t *h, hash_count_t m, hash_count_t max_keys, 57 57 hash_table_operations_t *op) 58 58 { … … 61 61 assert(max_keys > 0); 62 62 63 h->entry = malloc(m * sizeof(li st_t));63 h->entry = malloc(m * sizeof(link_t)); 64 64 if (!h->entry) 65 65 return false; 66 66 67 memset((void *) h->entry, 0, m * sizeof(li st_t));67 memset((void *) h->entry, 0, m * sizeof(link_t)); 68 68 69 69 hash_count_t i; … … 123 123 assert(chain < h->entries); 124 124 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) { 126 128 if (h->op->compare(key, h->max_keys, cur)) { 127 129 /* … … 151 153 assert(keys <= h->max_keys); 152 154 155 link_t *cur; 156 153 157 if (keys == h->max_keys) { 154 link_t *cur;155 156 158 /* 157 159 * All keys are known, hash_table_find() can be used to find the … … 174 176 hash_index_t chain; 175 177 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]; 179 179 cur = cur->next) { 180 180 if (h->op->compare(key, keys, cur)) { … … 203 203 { 204 204 hash_index_t bucket; 205 link_t *cur; 205 206 206 207 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) { 208 210 f(cur, arg); 209 211 }
Note:
See TracChangeset
for help on using the changeset viewer.