Changeset 0ca7286 in mainline for uspace/lib/nic/src/nic_wol_virtues.c
- Timestamp:
- 2012-07-21T11:19:27Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2732c94
- Parents:
- 1c1da4b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/nic/src/nic_wol_virtues.c
r1c1da4b r0ca7286 40 40 #include <errno.h> 41 41 42 #define NIC_WV_HASH_COUNT 32 43 44 /** 45 * Hash table helper function 46 */ 47 static int nic_wv_compare(unsigned long key[], hash_count_t keys, 48 link_t *item) 42 43 /* 44 * Hash table helper functions 45 */ 46 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) 53 { 54 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) 49 60 { 50 61 nic_wol_virtue_t *virtue = (nic_wol_virtue_t *) item; … … 53 64 54 65 /** 55 * Hash table helper function56 */57 static void nic_wv_rc(link_t *item)58 {59 }60 61 /**62 * Hash table helper function63 */64 static hash_index_t nic_wv_hash(unsigned long keys[])65 {66 return keys[0] % NIC_WV_HASH_COUNT;67 }68 69 /**70 66 * Initializes the WOL virtues structure 71 67 * … … 77 73 int nic_wol_virtues_init(nic_wol_virtues_t *wvs) 78 74 { 79 bzero(wvs, sizeof (nic_wol_virtues_t)); 80 wvs->table_operations.compare = nic_wv_compare; 75 bzero(wvs, sizeof(nic_wol_virtues_t)); 81 76 wvs->table_operations.hash = nic_wv_hash; 82 wvs->table_operations.remove_callback = nic_wv_rc; 83 if (!hash_table_create(&wvs->table, NIC_WV_HASH_COUNT, 1, 84 &wvs->table_operations)) { 77 wvs->table_operations.key_hash = nic_wv_key_hash; 78 wvs->table_operations.match = nic_wv_match; 79 wvs->table_operations.equal = 0; 80 wvs->table_operations.remove_callback = 0; 81 82 if (!hash_table_create(&wvs->table, 0, 1, &wvs->table_operations)) { 85 83 return ENOMEM; 86 84 } … … 172 170 } while (NULL != 173 171 hash_table_find(&wvs->table, (unsigned long *) &virtue->id)); 174 hash_table_insert(&wvs->table, 175 (unsigned long *) &virtue->id, &virtue->item); 172 hash_table_insert(&wvs->table, &virtue->item); 176 173 virtue->next = wvs->lists[virtue->type]; 177 174 wvs->lists[virtue->type] = virtue;
Note:
See TracChangeset
for help on using the changeset viewer.