}
while (evict_count > 0) {
- khiter_t pos = seed++ % kh_end(cache->map);
+ khiter_t pos = seed++ % git_oidmap_end(cache->map);
if (kh_exist(cache->map, pos)) {
git_cached_obj *evict = kh_val(cache->map, pos);
return NULL;
pos = kh_get(oid, cache->map, oid);
- if (pos != kh_end(cache->map)) {
+ if (git_oidmap_valid_index(cache->map, pos)) {
entry = kh_val(cache->map, pos);
if (flags && entry->flags != flags) {
pos = kh_get(oid, cache->map, &entry->oid);
/* not found */
- if (pos == kh_end(cache->map)) {
+ if (!git_oidmap_valid_index(cache->map, pos)) {
int rval;
pos = kh_put(oid, cache->map, &entry->oid, &rval);
khiter_t pos;
pos = kh_get(oid, db->objects, oid);
- if (pos == kh_end(db->objects))
+ if (!git_oidmap_valid_index(db->objects, pos))
return GIT_ENOTFOUND;
obj = kh_val(db->objects, pos);
khiter_t pos;
pos = kh_get(oid, db->objects, oid);
- if (pos == kh_end(db->objects))
+ if (!git_oidmap_valid_index(db->objects, pos))
return GIT_ENOTFOUND;
obj = kh_val(db->objects, pos);
#define git_oidmap_foreach_value kh_foreach_value
+#define git_oidmap_begin kh_begin
+#define git_oidmap_end kh_end
+
#define git_oidmap_size(h) kh_size(h)
#define git_oidmap_clear(h) kh_clear(oid, h)
GIT_UNUSED(name);
pos = kh_get(oid, pb->object_ix, oid);
- if (pos == kh_end(pb->object_ix))
+ if (!git_oidmap_valid_index(pb->object_ix, pos))
return 0;
po = kh_value(pb->object_ix, pos);
return NULL;
k = kh_get(off, cache->entries, offset);
- if (k != kh_end(cache->entries)) { /* found it */
+ if (git_offmap_valid_index(cache->entries, k)) { /* found it */
entry = kh_value(cache->entries, k);
git_atomic_inc(&entry->refcount);
entry->last_usage = cache->use_ctr++;
git_oid_fromraw(&oid, base_info);
k = kh_get(oid, p->idx_cache, &oid);
- if (k != kh_end(p->idx_cache)) {
+ if (git_oidmap_valid_index(p->idx_cache, k)) {
*curpos += 20;
return ((struct git_pack_entry *)kh_value(p->idx_cache, k))->offset;
} else {
/* lookup and reserve space if not already present */
pos = kh_get(oid, walk->commits, oid);
- if (pos != kh_end(walk->commits))
+ if (git_oidmap_valid_index(walk->commits, pos))
return kh_value(walk->commits, pos);
commit = git_commit_list_alloc_node(walk);
int ret;
pos = kh_get(oid, map, &items[i].oid);
- cl_assert(pos == kh_end(map));
+ cl_assert(!git_oidmap_valid_index(map, pos));
pos = kh_put(oid, map, &items[i].oid, &ret);
cl_assert(ret != 0);
khiter_t pos;
pos = kh_get(oid, map, &items[i].oid);
- cl_assert(pos != kh_end(map));
+ cl_assert(git_oidmap_valid_index(map, pos));
cl_assert_equal_p(kh_val(map, pos), &items[i]);
}
int ret;
pos = kh_get(oid, map, &items[i].oid);
- cl_assert(pos == kh_end(map));
+ cl_assert(!git_oidmap_valid_index(map, pos));
pos = kh_put(oid, map, &items[i].oid, &ret);
cl_assert(ret != 0);
khiter_t pos;
pos = kh_get(oid, map, &items[i].oid);
- cl_assert(pos != kh_end(map));
+ cl_assert(git_oidmap_valid_index(map, pos));
cl_assert_equal_p(kh_val(map, pos), &items[i]);
}