summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-01-25 14:26:58 +0100
committerPatrick Steinhardt <ps@pks.im>2017-02-17 11:41:06 +0100
commitcb18386f72f07fc7316a0be892b98185d4aef7ce (patch)
tree93dc35b432d773d7fd279887bda65601ca6b2ca4
parent76e671a653360f816765fe55b367d29946361490 (diff)
downloadlibgit2-cb18386f72f07fc7316a0be892b98185d4aef7ce.tar.gz
khash: avoid using `kh_val`/`kh_value` directly
-rw-r--r--src/cache.c10
-rw-r--r--src/indexer.c4
-rw-r--r--src/odb_mempack.c6
-rw-r--r--src/pack-objects.c6
-rw-r--r--src/pack.c6
-rw-r--r--src/revwalk.c4
-rw-r--r--src/sortedcache.c2
-rw-r--r--tests/core/oidmap.c8
8 files changed, 23 insertions, 23 deletions
diff --git a/src/cache.c b/src/cache.c
index ae42216c9..c5f576a80 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -128,7 +128,7 @@ static void cache_evict_entries(git_cache *cache)
khiter_t pos = seed++ % git_oidmap_end(cache->map);
if (git_oidmap_has_data(cache->map, pos)) {
- git_cached_obj *evict = kh_val(cache->map, pos);
+ git_cached_obj *evict = git_oidmap_value_at(cache->map, pos);
evict_count--;
evicted_memory += evict->size;
@@ -158,7 +158,7 @@ static void *cache_get(git_cache *cache, const git_oid *oid, unsigned int flags)
pos = git_oidmap_lookup_index(cache->map, oid);
if (git_oidmap_valid_index(cache->map, pos)) {
- entry = kh_val(cache->map, pos);
+ entry = git_oidmap_value_at(cache->map, pos);
if (flags && entry->flags != flags) {
entry = NULL;
@@ -202,7 +202,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
pos = kh_put(oid, cache->map, &entry->oid, &rval);
if (rval >= 0) {
kh_key(cache->map, pos) = &entry->oid;
- kh_val(cache->map, pos) = entry;
+ git_oidmap_value_at(cache->map, pos) = entry;
git_cached_obj_incref(entry);
cache->used_memory += entry->size;
git_atomic_ssize_add(&git_cache__current_storage, (ssize_t)entry->size);
@@ -210,7 +210,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
}
/* found */
else {
- git_cached_obj *stored_entry = kh_val(cache->map, pos);
+ git_cached_obj *stored_entry = git_oidmap_value_at(cache->map, pos);
if (stored_entry->flags == entry->flags) {
git_cached_obj_decref(entry);
@@ -222,7 +222,7 @@ static void *cache_store(git_cache *cache, git_cached_obj *entry)
git_cached_obj_incref(entry);
kh_key(cache->map, pos) = &entry->oid;
- kh_val(cache->map, pos) = entry;
+ git_oidmap_value_at(cache->map, pos) = entry;
} else {
/* NO OP */
}
diff --git a/src/indexer.c b/src/indexer.c
index b5d5fd0d2..303dd7cc7 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -308,7 +308,7 @@ static int store_object(git_indexer *idx)
}
- kh_value(idx->pack->idx_cache, k) = pentry;
+ git_oidmap_value_at(idx->pack->idx_cache, k) = pentry;
git_oid_cpy(&entry->oid, &oid);
@@ -356,7 +356,7 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
return -1;
}
- kh_value(idx->pack->idx_cache, k) = pentry;
+ git_oidmap_value_at(idx->pack->idx_cache, k) = pentry;
/* Add the object to the list */
if (git_vector_insert(&idx->objects, entry) < 0)
diff --git a/src/odb_mempack.c b/src/odb_mempack.c
index b55ce7310..1b8987ef8 100644
--- a/src/odb_mempack.c
+++ b/src/odb_mempack.c
@@ -58,7 +58,7 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void
obj->type = type;
kh_key(db->objects, pos) = &obj->oid;
- kh_val(db->objects, pos) = obj;
+ git_oidmap_value_at(db->objects, pos) = obj;
if (type == GIT_OBJ_COMMIT) {
struct memobject **store = git_array_alloc(db->commits);
@@ -86,7 +86,7 @@ static int impl__read(void **buffer_p, size_t *len_p, git_otype *type_p, git_odb
if (!git_oidmap_valid_index(db->objects, pos))
return GIT_ENOTFOUND;
- obj = kh_val(db->objects, pos);
+ obj = git_oidmap_value_at(db->objects, pos);
*len_p = obj->len;
*type_p = obj->type;
@@ -107,7 +107,7 @@ static int impl__read_header(size_t *len_p, git_otype *type_p, git_odb_backend *
if (!git_oidmap_valid_index(db->objects, pos))
return GIT_ENOTFOUND;
- obj = kh_val(db->objects, pos);
+ obj = git_oidmap_value_at(db->objects, pos);
*len_p = obj->len;
*type_p = obj->type;
diff --git a/src/pack-objects.c b/src/pack-objects.c
index e463820e4..01286fa56 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -200,7 +200,7 @@ static void rehash(git_packbuilder *pb)
git_oidmap_clear(pb->object_ix);
for (i = 0, po = pb->object_list; i < pb->nr_objects; i++, po++) {
pos = kh_put(oid, pb->object_ix, &po->id, &ret);
- kh_value(pb->object_ix, pos) = po;
+ git_oidmap_value_at(pb->object_ix, pos) = po;
}
}
@@ -252,7 +252,7 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
return ret;
}
assert(ret != 0);
- kh_value(pb->object_ix, pos) = po;
+ git_oidmap_value_at(pb->object_ix, pos) = po;
pb->done = false;
@@ -520,7 +520,7 @@ static int cb_tag_foreach(const char *name, git_oid *oid, void *data)
if (!git_oidmap_valid_index(pb->object_ix, pos))
return 0;
- po = kh_value(pb->object_ix, pos);
+ po = git_oidmap_value_at(pb->object_ix, pos);
po->tagged = 1;
/* TODO: peel objects */
diff --git a/src/pack.c b/src/pack.c
index 43ef09801..4c2b9ebe0 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -119,7 +119,7 @@ static git_pack_cache_entry *cache_get(git_pack_cache *cache, git_off_t offset)
k = git_offmap_lookup_index(cache->entries, offset);
if (git_offmap_valid_index(cache->entries, k)) { /* found it */
- entry = kh_value(cache->entries, k);
+ entry = git_offmap_value_at(cache->entries, k);
git_atomic_inc(&entry->refcount);
entry->last_usage = cache->use_ctr++;
}
@@ -171,7 +171,7 @@ static int cache_add(
k = kh_put(off, cache->entries, offset, &error);
assert(error != 0);
- kh_value(cache->entries, k) = entry;
+ git_oidmap_value_at(cache->entries, k) = entry;
cache->memory_used += entry->raw.len;
*cached_out = entry;
@@ -959,7 +959,7 @@ git_off_t get_delta_base(
k = git_oidmap_lookup_index(p->idx_cache, &oid);
if (git_oidmap_valid_index(p->idx_cache, k)) {
*curpos += 20;
- return ((struct git_pack_entry *)kh_value(p->idx_cache, k))->offset;
+ return ((struct git_pack_entry *)git_oidmap_value_at(p->idx_cache, k))->offset;
} else {
/* If we're building an index, don't try to find the pack
* entry; we just haven't seen it yet. We'll make
diff --git a/src/revwalk.c b/src/revwalk.c
index 752666509..32a4ff906 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -27,7 +27,7 @@ git_commit_list_node *git_revwalk__commit_lookup(
/* lookup and reserve space if not already present */
pos = git_oidmap_lookup_index(walk->commits, oid);
if (git_oidmap_valid_index(walk->commits, pos))
- return kh_value(walk->commits, pos);
+ return git_oidmap_value_at(walk->commits, pos);
commit = git_commit_list_alloc_node(walk);
if (commit == NULL)
@@ -37,7 +37,7 @@ git_commit_list_node *git_revwalk__commit_lookup(
pos = kh_put(oid, walk->commits, &commit->oid, &ret);
assert(ret != 0);
- kh_value(walk->commits, pos) = commit;
+ git_oidmap_value_at(walk->commits, pos) = commit;
return commit;
}
diff --git a/src/sortedcache.c b/src/sortedcache.c
index c5e338f75..48e8b6c71 100644
--- a/src/sortedcache.c
+++ b/src/sortedcache.c
@@ -300,7 +300,7 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key)
if (!error)
kh_key(sc->map, pos) = item_key;
- kh_val(sc->map, pos) = item;
+ git_strmap_value_at(sc->map, pos) = item;
error = git_vector_insert(&sc->items, item);
if (error < 0)
diff --git a/tests/core/oidmap.c b/tests/core/oidmap.c
index 2255e3936..61d75e9d1 100644
--- a/tests/core/oidmap.c
+++ b/tests/core/oidmap.c
@@ -39,7 +39,7 @@ void test_core_oidmap__basic(void)
pos = kh_put(oid, map, &items[i].oid, &ret);
cl_assert(ret != 0);
- kh_val(map, pos) = &items[i];
+ git_oidmap_value_at(map, pos) = &items[i];
}
@@ -49,7 +49,7 @@ void test_core_oidmap__basic(void)
pos = git_oidmap_lookup_index(map, &items[i].oid);
cl_assert(git_oidmap_valid_index(map, pos));
- cl_assert_equal_p(kh_val(map, pos), &items[i]);
+ cl_assert_equal_p(git_oidmap_value_at(map, pos), &items[i]);
}
git_oidmap_free(map);
@@ -93,7 +93,7 @@ void test_core_oidmap__hash_collision(void)
pos = kh_put(oid, map, &items[i].oid, &ret);
cl_assert(ret != 0);
- kh_val(map, pos) = &items[i];
+ git_oidmap_value_at(map, pos) = &items[i];
}
@@ -103,7 +103,7 @@ void test_core_oidmap__hash_collision(void)
pos = git_oidmap_lookup_index(map, &items[i].oid);
cl_assert(git_oidmap_valid_index(map, pos));
- cl_assert_equal_p(kh_val(map, pos), &items[i]);
+ cl_assert_equal_p(git_oidmap_value_at(map, pos), &items[i]);
}
git_oidmap_free(map);