mirror of
https://github.com/git/git.git
synced 2026-01-09 01:34:00 +00:00
for_each_hash: allow passing a 'void *data' pointer to callback
For the find_exact_renames() function, this allows us to pass the diff_options structure pointer to the low-level routines. We will use that to distinguish between the "rename" and "copy" cases. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
7ed863a85a
commit
11f944dd6b
4
hash.c
4
hash.c
@@ -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(const 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(const 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;
|
||||
|
||||
Reference in New Issue
Block a user