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:
@@ -58,22 +58,6 @@ struct private_ha_cache_t {
|
||||
mutex_t *mutex;
|
||||
};
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache entry for an IKE_SA
|
||||
*/
|
||||
@@ -380,7 +364,7 @@ ha_cache_t *ha_cache_create(ha_kernel_t *kernel, ha_socket_t *socket,
|
||||
.count = count,
|
||||
.kernel = kernel,
|
||||
.socket = socket,
|
||||
.cache = hashtable_create(hash, equals, 8),
|
||||
.cache = hashtable_create(hashtable_hash_ptr, hashtable_equals_ptr, 8),
|
||||
.mutex = mutex_create(MUTEX_TYPE_DEFAULT),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user