Changeset bc216a0 in mainline for uspace/lib/nic/src/nic_wol_virtues.c
- Timestamp:
- 2012-08-07T22:13:44Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- da68871a
- Parents:
- b17518e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/nic/src/nic_wol_virtues.c
rb17518e rbc216a0 37 37 38 38 #include "nic_wol_virtues.h" 39 #include "nic.h" 39 40 #include <assert.h> 40 41 #include <errno.h> … … 45 46 */ 46 47 47 static size_t nic_wv_key_hash( unsigned long keys[])48 { 49 return keys[0];50 } 51 52 static size_t nic_wv_hash(const link_t *item)48 static size_t nic_wv_key_hash(void *key) 49 { 50 return *(nic_wv_id_t*) key; 51 } 52 53 static size_t nic_wv_hash(const ht_link_t *item) 53 54 { 54 55 nic_wol_virtue_t *virtue = (nic_wol_virtue_t *) item; 55 unsigned long key = virtue->id; 56 return nic_wv_key_hash(&key); 57 } 58 59 static bool nic_wv_match(unsigned long key[], size_t keys, const link_t *item) 56 return virtue->id; 57 } 58 59 static bool nic_wv_key_equal(void *key, const ht_link_t *item) 60 60 { 61 61 nic_wol_virtue_t *virtue = (nic_wol_virtue_t *) item; 62 return (virtue->id == (nic_wv_id_t) key[0]);62 return (virtue->id == *(nic_wv_id_t*) key); 63 63 } 64 64 … … 76 76 wvs->table_operations.hash = nic_wv_hash; 77 77 wvs->table_operations.key_hash = nic_wv_key_hash; 78 wvs->table_operations. match = nic_wv_match;78 wvs->table_operations.key_equal = nic_wv_key_equal; 79 79 wvs->table_operations.equal = 0; 80 80 wvs->table_operations.remove_callback = 0; 81 81 82 if (!hash_table_create(&wvs->table, 0, 1, &wvs->table_operations)) {82 if (!hash_table_create(&wvs->table, 0, 0, &wvs->table_operations)) { 83 83 return ENOMEM; 84 84 } … … 168 168 do { 169 169 virtue->id = wvs->next_id++; 170 } while (NULL != 171 hash_table_find(&wvs->table, (unsigned long *) &virtue->id)); 170 } while (NULL != hash_table_find(&wvs->table, &virtue->id)); 172 171 hash_table_insert(&wvs->table, &virtue->item); 173 172 virtue->next = wvs->lists[virtue->type]; … … 188 187 nic_wol_virtue_t *nic_wol_virtues_remove(nic_wol_virtues_t *wvs, nic_wv_id_t id) 189 188 { 190 nic_wol_virtue_t *virtue = (nic_wol_virtue_t *)191 hash_table_find(&wvs->table, (unsigned long *)&id);189 nic_wol_virtue_t *virtue = 190 (nic_wol_virtue_t *) hash_table_find(&wvs->table, &id); 192 191 if (virtue == NULL) { 193 192 return NULL; … … 195 194 196 195 /* Remove from filter_table */ 197 hash_table_remove (&wvs->table, (unsigned long *) &id, 1);196 hash_table_remove_item(&wvs->table, &virtue->item); 198 197 199 198 /* Remove from filter_types */ … … 232 231 * constant virtue the retyping is correct. 233 232 */ 234 link_t *virtue = hash_table_find( 235 &((nic_wol_virtues_t *) wvs)->table, (unsigned long *) &id); 233 ht_link_t *virtue = hash_table_find(&((nic_wol_virtues_t *) wvs)->table, &id); 236 234 return (const nic_wol_virtue_t *) virtue; 237 235 }
Note:
See TracChangeset
for help on using the changeset viewer.