diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-07-13 16:14:54 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-07-13 16:14:54 -0700 |
commit | 91f69225443b3be8d3f11c5c71795169d7d00737 (patch) | |
tree | 7c891653d8fb17dfb29641cc8e56385064816e94 /t | |
parent | Merge branch 'ab/grep-lose-opt-regflags' (diff) | |
parent | hashmap: migrate documentation from Documentation/technical into header (diff) | |
download | tgif-91f69225443b3be8d3f11c5c71795169d7d00737.tar.xz |
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')
-rw-r--r-- | t/helper/test-hashmap.c | 19 |
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)) { |