diff options
author | nulltoken <emeric.fermas@gmail.com> | 2012-11-15 09:08:30 -0800 |
---|---|---|
committer | Carlos MartÃn Nieto <cmn@dwim.me> | 2014-04-30 09:31:58 +0200 |
commit | de1e81aa10e02f286f39c73cda9899908c448790 (patch) | |
tree | 6720639e8bc7212a59afb65122732ba6d2f95e16 | |
parent | 892778ee84e741f111b103570854ff37b110f74d (diff) | |
download | libgit2-de1e81aa10e02f286f39c73cda9899908c448790.tar.gz |
oidmap: Enhance the khash wrapper
-rw-r--r-- | src/oidmap.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/oidmap.h b/src/oidmap.h index a29c7cd35..50da54b1c 100644 --- a/src/oidmap.h +++ b/src/oidmap.h @@ -32,4 +32,17 @@ GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid) #define git_oidmap_alloc() kh_init(oid) #define git_oidmap_free(h) kh_destroy(oid,h), h = NULL +#define git_oidmap_lookup_index(h, k) kh_get(oid, h, k) +#define git_oidmap_valid_index(h, idx) (idx != kh_end(h)) + +#define git_oidmap_value_at(h, idx) kh_val(h, idx) + +#define git_oidmap_insert(h, key, val, rval) do { \ + khiter_t __pos = kh_put(oid, h, key, &rval); \ + if (rval >= 0) { \ + if (rval == 0) kh_key(h, __pos) = key; \ + kh_val(h, __pos) = val; \ + } } while (0) + +#define git_oidmap_foreach_value kh_foreach_value #endif |