summaryrefslogtreecommitdiff
path: root/blame.c
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-10-06 23:30:41 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-10-07 01:20:11 (GMT)
commit23dee69f53cf5024ca79e0b707dcb03c63f33bef (patch)
treee99f2fd2a4e1fe622451eeaafa8c37b40413ec10 /blame.c
parentc8e424c9c94d97b18cd335be17f32a8ce94a5b7f (diff)
downloadgit-23dee69f53cf5024ca79e0b707dcb03c63f33bef.zip
git-23dee69f53cf5024ca79e0b707dcb03c63f33bef.tar.gz
git-23dee69f53cf5024ca79e0b707dcb03c63f33bef.tar.bz2
OFFSETOF_VAR macro to simplify hashmap iterators
While we cannot rely on a `__typeof__' operator being portable to use with `offsetof'; we can calculate the pointer offset using an existing pointer and the address of a member using pointer arithmetic for compilers without `__typeof__'. This allows us to simplify usage of hashmap iterator macros by not having to specify a type when a pointer of that type is already given. In the future, list iterator macros (e.g. list_for_each_entry) may also be implemented using OFFSETOF_VAR to save hackers the trouble of using container_of/list_entry macros and without relying on non-portable `__typeof__'. v3: use `__typeof__' to avoid clang warnings Signed-off-by: Eric Wong <e@80x24.org> Reviewed-by: Derrick Stolee <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'blame.c')
-rw-r--r--blame.c2
1 files changed, 0 insertions, 2 deletions
diff --git a/blame.c b/blame.c
index f33af0d..90b247a 100644
--- a/blame.c
+++ b/blame.c
@@ -451,7 +451,6 @@ static int fingerprint_similarity(struct fingerprint *a, struct fingerprint *b)
const struct fingerprint_entry *entry_a, *entry_b;
hashmap_for_each_entry(&b->map, &iter, entry_b,
- const struct fingerprint_entry,
entry /* member name */) {
entry_a = hashmap_get_entry(&a->map, entry_b, NULL,
struct fingerprint_entry, entry);
@@ -474,7 +473,6 @@ static void fingerprint_subtract(struct fingerprint *a, struct fingerprint *b)
hashmap_iter_init(&b->map, &iter);
hashmap_for_each_entry(&b->map, &iter, entry_b,
- const struct fingerprint_entry,
entry /* member name */) {
entry_a = hashmap_get_entry(&a->map, entry_b, NULL,
struct fingerprint_entry, entry);