aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/hash_table.h9
-rw-r--r--lib/sqfs/block_processor/common.c6
-rw-r--r--lib/util/hash_table.c18
3 files changed, 19 insertions, 14 deletions
diff --git a/include/hash_table.h b/include/hash_table.h
index 6f377c9..813e059 100644
--- a/include/hash_table.h
+++ b/include/hash_table.h
@@ -42,9 +42,10 @@ struct hash_entry {
struct hash_table {
struct hash_entry *table;
- sqfs_u32 (*key_hash_function)(const void *key);
- bool (*key_equals_function)(const void *a, const void *b);
+ sqfs_u32 (*key_hash_function)(void *user, const void *key);
+ bool (*key_equals_function)(void *user, const void *a, const void *b);
const void *deleted_key;
+ void *user;
sqfs_u32 size;
sqfs_u32 rehash;
sqfs_u64 size_magic;
@@ -56,8 +57,8 @@ struct hash_table {
};
SQFS_INTERNAL struct hash_table *
-hash_table_create(sqfs_u32 (*key_hash_function)(const void *key),
- bool (*key_equals_function)(const void *a,
+hash_table_create(sqfs_u32 (*key_hash_function)(void *user, const void *key),
+ bool (*key_equals_function)(void *user, const void *a,
const void *b));
SQFS_INTERNAL struct hash_table *
diff --git a/lib/sqfs/block_processor/common.c b/lib/sqfs/block_processor/common.c
index 1e42042..97cb790 100644
--- a/lib/sqfs/block_processor/common.c
+++ b/lib/sqfs/block_processor/common.c
@@ -261,15 +261,17 @@ fail_outblk:
return err;
}
-static uint32_t chunk_info_hash(const void *key)
+static uint32_t chunk_info_hash(void *user, const void *key)
{
const chunk_info_t *chunk = key;
+ (void)user;
return chunk->hash;
}
-static bool chunk_info_equals(const void *a, const void *b)
+static bool chunk_info_equals(void *user, const void *a, const void *b)
{
const chunk_info_t *a_ = a, *b_ = b;
+ (void)user;
return a_->size == b_->size &&
a_->hash == b_->hash;
}
diff --git a/lib/util/hash_table.c b/lib/util/hash_table.c
index 63882f3..a78aeee 100644
--- a/lib/util/hash_table.c
+++ b/lib/util/hash_table.c
@@ -123,8 +123,8 @@ entry_is_present(const struct hash_table *ht, struct hash_entry *entry)
static bool
hash_table_init(struct hash_table *ht,
- sqfs_u32 (*key_hash_function)(const void *key),
- bool (*key_equals_function)(const void *a,
+ sqfs_u32 (*key_hash_function)(void *user, const void *key),
+ bool (*key_equals_function)(void *user, const void *a,
const void *b))
{
ht->size_index = 0;
@@ -144,8 +144,8 @@ hash_table_init(struct hash_table *ht,
}
struct hash_table *
-hash_table_create(sqfs_u32 (*key_hash_function)(const void *key),
- bool (*key_equals_function)(const void *a,
+hash_table_create(sqfs_u32 (*key_hash_function)(void *user, const void *key),
+ bool (*key_equals_function)(void *user, const void *a,
const void *b))
{
struct hash_table *ht;
@@ -220,7 +220,7 @@ hash_table_search(struct hash_table *ht, sqfs_u32 hash, const void *key)
if (entry_is_free(entry)) {
return NULL;
} else if (entry_is_present(ht, entry) && entry->hash == hash) {
- if (ht->key_equals_function(key, entry->key)) {
+ if (ht->key_equals_function(ht->user, key, entry->key)) {
return entry;
}
}
@@ -243,7 +243,8 @@ struct hash_entry *
hash_table_search_pre_hashed(struct hash_table *ht, sqfs_u32 hash,
const void *key)
{
- assert(ht->key_hash_function == NULL || hash == ht->key_hash_function(key));
+ assert(ht->key_hash_function == NULL ||
+ hash == ht->key_hash_function(ht->user, key));
return hash_table_search(ht, hash, key);
}
@@ -349,7 +350,7 @@ hash_table_insert(struct hash_table *ht, sqfs_u32 hash,
*/
if (!entry_is_deleted(ht, entry) &&
entry->hash == hash &&
- ht->key_equals_function(key, entry->key)) {
+ ht->key_equals_function(ht->user, key, entry->key)) {
entry->key = key;
entry->data = data;
return entry;
@@ -386,7 +387,8 @@ struct hash_entry *
hash_table_insert_pre_hashed(struct hash_table *ht, sqfs_u32 hash,
const void *key, void *data)
{
- assert(ht->key_hash_function == NULL || hash == ht->key_hash_function(key));
+ assert(ht->key_hash_function == NULL ||
+ hash == ht->key_hash_function(ht->user, key));
return hash_table_insert(ht, hash, key, data);
}