Changeset 0ca7286 in mainline for uspace/srv/ns/service.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/srv/ns/service.c
r1c1da4b r0ca7286 40 40 #include "ns.h" 41 41 42 #define SERVICE_HASH_TABLE_CHAINS 2043 42 44 43 /** Service hash table item. */ … … 58 57 * 59 58 */ 60 static hash_index_t service_hash(unsigned long key[])59 static size_t service_key_hash(unsigned long key[]) 61 60 { 62 61 assert(key); 63 return (key[0] % SERVICE_HASH_TABLE_CHAINS); 62 return key[0]; 63 } 64 65 static size_t service_hash(const link_t *item) 66 { 67 hashed_service_t *hs = hash_table_get_instance(item, hashed_service_t, link); 68 unsigned long key = hs->service; 69 return service_key_hash(&key); 64 70 } 65 71 … … 79 85 * 80 86 */ 81 static int service_compare(unsigned long key[], hash_count_t keys,link_t *item)87 static bool service_match(unsigned long key[], size_t keys, const link_t *item) 82 88 { 83 89 assert(key); … … 105 111 106 112 /** Operations for service hash table. */ 107 static hash_table_op erations_t service_hash_table_ops = {113 static hash_table_ops_t service_hash_table_ops = { 108 114 .hash = service_hash, 109 .compare = service_compare, 115 .key_hash = service_key_hash, 116 .match = service_match, 117 .equal = 0, 110 118 .remove_callback = service_remove 111 119 }; … … 127 135 int service_init(void) 128 136 { 129 if (!hash_table_create(&service_hash_table, SERVICE_HASH_TABLE_CHAINS, 130 3, &service_hash_table_ops)) { 137 if (!hash_table_create(&service_hash_table, 0, 3, &service_hash_table_ops)) { 131 138 printf(NAME ": No memory available for services\n"); 132 139 return ENOMEM; … … 193 200 hs->phone = phone; 194 201 hs->in_phone_hash = call->in_phone_hash; 195 hash_table_insert(&service_hash_table, keys,&hs->link);202 hash_table_insert(&service_hash_table, &hs->link); 196 203 197 204 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.