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:
Tobias Brunner
2014-03-31 14:32:44 +02:00
parent 7522fcffd2
commit 3b09c02ec0
4 changed files with 7 additions and 71 deletions
+1 -17
View File
@@ -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),
);