diff options
| author | Patrick Steinhardt <ps@pks.im> | 2018-11-23 18:48:40 +0100 |
|---|---|---|
| committer | Patrick Steinhardt <ps@pks.im> | 2018-11-28 15:22:27 +0100 |
| commit | 5bfb3b58e37fc35a0838ca2fa8b38941e056cfcc (patch) | |
| tree | 34e6117aa1293641fe67864f5f5a7b6d3dda898f /src/oidmap.h | |
| parent | 382b668bf2019eb8fb7c0afc4d6e3132dca9510e (diff) | |
| download | libgit2-5bfb3b58e37fc35a0838ca2fa8b38941e056cfcc.tar.gz | |
khash: implement map-specific foreach macros
The current foreach map macros simply redirect to the type-indifferent
`kh_foreach` macro. As this type-indifferent macro directly accesses the
structures, the current implementation makes it impossible to make the
stuctures private to the implementation only. And making them private is
required to move out the khash include into the implementations to
decrease the namespace leak.
Diffstat (limited to 'src/oidmap.h')
| -rw-r--r-- | src/oidmap.h | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/oidmap.h b/src/oidmap.h index 8f6016af9..f34c03420 100644 --- a/src/oidmap.h +++ b/src/oidmap.h @@ -46,6 +46,11 @@ void git_oidmap_delete(git_oidmap *map, const git_oid *key); size_t git_oidmap_begin(git_oidmap *map); size_t git_oidmap_end(git_oidmap *map); -#define git_oidmap_foreach_value kh_foreach_value +#define git_oidmap_foreach_value(h, vvar, code) { size_t __i; \ + for (__i = git_oidmap_begin(h); __i != git_oidmap_end(h); ++__i) { \ + if (!git_oidmap_has_data(h,__i)) continue; \ + (vvar) = git_oidmap_value_at(h,__i); \ + code; \ + } } #endif |
