Properly hash pointers for hash tables where appropriate
Simply using the pointer is not optimal for our hash table implementation, which simply masks the key to determine the bucket.
This commit is contained in:
@@ -46,22 +46,6 @@ struct private_dhcp_provider_t {
|
||||
dhcp_socket_t *socket;
|
||||
};
|
||||
|
||||
/**
|
||||
* Hashtable hash function
|
||||
*/
|
||||
static u_int hash(void *key)
|
||||
{
|
||||
return (uintptr_t)key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hashtable equals function
|
||||
*/
|
||||
static bool equals(void *a, void *b)
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hash ID and host to a key
|
||||
*/
|
||||
@@ -226,7 +210,8 @@ dhcp_provider_t *dhcp_provider_create(dhcp_socket_t *socket)
|
||||
},
|
||||
.socket = socket,
|
||||
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
|
||||
.transactions = hashtable_create(hash, equals, 8),
|
||||
.transactions = hashtable_create(hashtable_hash_ptr,
|
||||
hashtable_equals_ptr, 8),
|
||||
);
|
||||
|
||||
return &this->public;
|
||||
|
||||
Reference in New Issue
Block a user