]> git.ipfire.org Git - thirdparty/git.git/blobdiff - hash.c
Merge branch 'maint'
[thirdparty/git.git] / hash.c
diff --git a/hash.c b/hash.c
index 7b492d4fc039898b975a1122b4e4eb90e3eb8923..749ecfe4841a6a2af6ba4fdc6c540fd3016178f1 100644 (file)
--- a/hash.c
+++ b/hash.c
@@ -9,7 +9,7 @@
  * the existing entry, or the empty slot if none existed. The caller
  * can then look at the (*ptr) to see whether it existed or not.
  */
-static struct hash_table_entry *lookup_hash_entry(unsigned int hash, struct hash_table *table)
+static struct hash_table_entry *lookup_hash_entry(unsigned int hash, const struct hash_table *table)
 {
        unsigned int size = table->size, nr = hash % size;
        struct hash_table_entry *array = table->array;
@@ -66,11 +66,11 @@ static void grow_hash_table(struct hash_table *table)
        free(old_array);
 }
 
-void *lookup_hash(unsigned int hash, struct hash_table *table)
+void *lookup_hash(unsigned int hash, const struct hash_table *table)
 {
        if (!table->array)
                return NULL;
-       return &lookup_hash_entry(hash, table)->ptr;
+       return lookup_hash_entry(hash, table)->ptr;
 }
 
 void **insert_hash(unsigned int hash, void *ptr, struct hash_table *table)
@@ -81,7 +81,7 @@ void **insert_hash(unsigned int hash, void *ptr, struct hash_table *table)
        return insert_hash_entry(hash, ptr, table);
 }
 
-int for_each_hash(struct hash_table *table, int (*fn)(void *))
+int for_each_hash(const struct hash_table *table, int (*fn)(void *, void *), void *data)
 {
        int sum = 0;
        unsigned int i;
@@ -92,7 +92,7 @@ int for_each_hash(struct hash_table *table, int (*fn)(void *))
                void *ptr = array->ptr;
                array++;
                if (ptr) {
-                       int val = fn(ptr);
+                       int val = fn(ptr, data);
                        if (val < 0)
                                return val;
                        sum += val;