Changeset 7a68fe5 in mainline for uspace/lib/c/generic/adt/hash_table.c
- Timestamp:
- 2011-10-10T06:58:55Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2ea6392
- Parents:
- e68c834 (diff), 80099c19 (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
-
uspace/lib/c/generic/adt/hash_table.c
re68c834 r7a68fe5 76 76 77 77 return true; 78 } 79 80 /** Remove all elements from the hash table 81 * 82 * @param h Hash table to be cleared 83 */ 84 void hash_table_clear(hash_table_t *h) 85 { 86 for (hash_count_t chain = 0; chain < h->entries; ++chain) { 87 link_t *cur; 88 link_t *next; 89 90 for (cur = h->entry[chain].head.next; 91 cur != &h->entry[chain].head; 92 cur = next) { 93 next = cur->next; 94 list_remove(cur); 95 h->op->remove_callback(cur); 96 } 97 } 78 98 } 79 99 … … 198 218 */ 199 219 void hash_table_apply(hash_table_t *h, void (*f)(link_t *, void *), void *arg) 200 { 201 hash_index_t bucket; 202 203 for (bucket = 0; bucket < h->entries; bucket++) { 204 list_foreach(h->entry[bucket], cur) { 220 { 221 for (hash_index_t bucket = 0; bucket < h->entries; bucket++) { 222 link_t *cur; 223 link_t *next; 224 225 for (cur = h->entry[bucket].head.next; cur != &h->entry[bucket].head; 226 cur = next) { 227 /* 228 * The next pointer must be stored prior to the functor 229 * call to allow using destructor as the functor (the 230 * free function could overwrite the cur->next pointer). 231 */ 232 next = cur->next; 205 233 f(cur, arg); 206 234 }
Note:
See TracChangeset
for help on using the changeset viewer.