Changeset 8ff0bd2 in mainline for kernel/generic/src/adt/hash_table.c
- Timestamp:
- 2011-09-04T11:30:58Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 03bc76a
- Parents:
- d2c67e7 (diff), deac215e (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/adt/hash_table.c
rd2c67e7 r8ff0bd2 62 62 ASSERT(max_keys > 0); 63 63 64 h->entry = (li nk_t *) malloc(m * sizeof(link_t), 0);64 h->entry = (list_t *) malloc(m * sizeof(list_t), 0); 65 65 if (!h->entry) 66 66 panic("Cannot allocate memory for hash table."); 67 67 68 memsetb(h->entry, m * sizeof(li nk_t), 0);68 memsetb(h->entry, m * sizeof(list_t), 0); 69 69 70 70 for (i = 0; i < m; i++) … … 107 107 link_t *hash_table_find(hash_table_t *h, sysarg_t key[]) 108 108 { 109 link_t *cur;110 109 size_t chain; 111 110 … … 118 117 ASSERT(chain < h->entries); 119 118 120 for (cur = h->entry[chain].next; cur != &h->entry[chain]; cur = cur->next) {119 list_foreach(h->entry[chain], cur) { 121 120 if (h->op->compare(key, h->max_keys, cur)) { 122 121 /* … … 141 140 { 142 141 size_t chain; 143 link_t *cur;144 142 145 143 ASSERT(h); … … 149 147 ASSERT(keys <= h->max_keys); 150 148 149 151 150 if (keys == h->max_keys) { 152 151 link_t *cur; 152 153 153 /* 154 154 * All keys are known, hash_table_find() can be used to find the entry. … … 169 169 */ 170 170 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) { 172 174 if (h->op->compare(key, keys, cur)) { 173 175 link_t *hlp;
Note:
See TracChangeset
for help on using the changeset viewer.