Changeset 892022a1 in mainline
- Timestamp:
- 2011-10-07T12:42:11Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f51b1d3
- Parents:
- f98bec0f
- Location:
- uspace/lib/c
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/adt/hash_table.c
rf98bec0f r892022a1 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 } -
uspace/lib/c/include/adt/hash_table.h
rf98bec0f r892022a1 86 86 extern bool hash_table_create(hash_table_t *, hash_count_t, hash_count_t, 87 87 hash_table_operations_t *); 88 extern void hash_table_clear(hash_table_t *); 88 89 extern void hash_table_insert(hash_table_t *, unsigned long [], link_t *); 89 90 extern link_t *hash_table_find(hash_table_t *, unsigned long []);
Note:
See TracChangeset
for help on using the changeset viewer.