Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/t/helper
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-07-14 02:14:54 +0300
committerJunio C Hamano <gitster@pobox.com>2017-07-14 02:14:54 +0300
commit91f69225443b3be8d3f11c5c71795169d7d00737 (patch)
tree7c891653d8fb17dfb29641cc8e56385064816e94 /t/helper
parenteac97b438c6734304c155604f4c36ac63f29ca6f (diff)
parent1ecbf31d0298a1ed952623108e23234d5cf37086 (diff)
Merge branch 'sb/hashmap-customize-comparison'
Update the hashmap API so that data to customize the behaviour of the comparison function can be specified at the time a hashmap is initialized. * sb/hashmap-customize-comparison: hashmap: migrate documentation from Documentation/technical into header patch-ids.c: use hashmap correctly hashmap.h: compare function has access to a data field
Diffstat (limited to 't/helper')
-rw-r--r--t/helper/test-hashmap.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/t/helper/test-hashmap.c b/t/helper/test-hashmap.c
index 7aa9440e27..095d7395f3 100644
--- a/t/helper/test-hashmap.c
+++ b/t/helper/test-hashmap.c
@@ -13,14 +13,18 @@ static const char *get_value(const struct test_entry *e)
return e->key + strlen(e->key) + 1;
}
-static int test_entry_cmp(const struct test_entry *e1,
- const struct test_entry *e2, const char* key)
+static int test_entry_cmp(const void *unused_cmp_data,
+ const struct test_entry *e1,
+ const struct test_entry *e2,
+ const char* key)
{
return strcmp(e1->key, key ? key : e2->key);
}
-static int test_entry_cmp_icase(const struct test_entry *e1,
- const struct test_entry *e2, const char* key)
+static int test_entry_cmp_icase(const void *unused_cmp_data,
+ const struct test_entry *e1,
+ const struct test_entry *e2,
+ const char* key)
{
return strcasecmp(e1->key, key ? key : e2->key);
}
@@ -92,7 +96,8 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
if (method & TEST_ADD) {
/* test adding to the map */
for (j = 0; j < rounds; j++) {
- hashmap_init(&map, (hashmap_cmp_fn) test_entry_cmp, 0);
+ hashmap_init(&map, (hashmap_cmp_fn) test_entry_cmp,
+ NULL, 0);
/* add entries */
for (i = 0; i < TEST_SIZE; i++) {
@@ -104,7 +109,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
}
} else {
/* test map lookups */
- hashmap_init(&map, (hashmap_cmp_fn) test_entry_cmp, 0);
+ hashmap_init(&map, (hashmap_cmp_fn) test_entry_cmp, NULL, 0);
/* fill the map (sparsely if specified) */
j = (method & TEST_SPARSE) ? TEST_SIZE / 10 : TEST_SIZE;
@@ -147,7 +152,7 @@ int cmd_main(int argc, const char **argv)
/* init hash map */
icase = argc > 1 && !strcmp("ignorecase", argv[1]);
hashmap_init(&map, (hashmap_cmp_fn) (icase ? test_entry_cmp_icase
- : test_entry_cmp), 0);
+ : test_entry_cmp), NULL, 0);
/* process commands from stdin */
while (fgets(line, sizeof(line), stdin)) {