summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/indexer.c4
-rw-r--r--src/odb_mempack.c2
-rw-r--r--src/offmap.h2
-rw-r--r--src/oidmap.h2
-rw-r--r--src/pack-objects.c4
-rw-r--r--src/pack.c2
-rw-r--r--src/revwalk.c2
-rw-r--r--src/sortedcache.c2
-rw-r--r--src/strmap.h2
-rw-r--r--src/submodule.c2
-rw-r--r--tests/core/oidmap.c4
11 files changed, 17 insertions, 11 deletions
diff --git a/src/indexer.c b/src/indexer.c
index 303dd7cc7..888a06cdb 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -294,7 +294,7 @@ static int store_object(git_indexer *idx)
git_oid_cpy(&pentry->sha1, &oid);
pentry->offset = entry_start;
- k = kh_put(oid, idx->pack->idx_cache, &pentry->sha1, &error);
+ k = git_oidmap_put(idx->pack->idx_cache, &pentry->sha1, &error);
if (error == -1) {
git__free(pentry);
giterr_set_oom();
@@ -349,7 +349,7 @@ static int save_entry(git_indexer *idx, struct entry *entry, struct git_pack_ent
}
pentry->offset = entry_start;
- k = kh_put(oid, idx->pack->idx_cache, &pentry->sha1, &error);
+ k = git_oidmap_put(idx->pack->idx_cache, &pentry->sha1, &error);
if (error <= 0) {
giterr_set(GITERR_INDEXER, "cannot insert object into pack");
diff --git a/src/odb_mempack.c b/src/odb_mempack.c
index 3165710b5..da3d85f78 100644
--- a/src/odb_mempack.c
+++ b/src/odb_mempack.c
@@ -41,7 +41,7 @@ static int impl__write(git_odb_backend *_backend, const git_oid *oid, const void
size_t alloc_len;
int rval;
- pos = kh_put(oid, db->objects, oid, &rval);
+ pos = git_oidmap_put(db->objects, oid, &rval);
if (rval < 0)
return -1;
diff --git a/src/offmap.h b/src/offmap.h
index 4476cf772..1fcd9f68b 100644
--- a/src/offmap.h
+++ b/src/offmap.h
@@ -38,6 +38,8 @@ typedef khash_t(off) git_offmap;
#define git_offmap_set_value_at(h, idx, v) kh_val(h, idx) = v
#define git_offmap_delete_at(h, idx) kh_del(off, h, idx)
+#define git_offmap_put(h, k, err) kh_put(off, h, k, err)
+
#define git_offmap_insert(h, key, val, rval) do { \
khiter_t __pos = kh_put(off, h, key, &rval); \
if (rval >= 0) { \
diff --git a/src/oidmap.h b/src/oidmap.h
index 8eb8e28c0..c34547aae 100644
--- a/src/oidmap.h
+++ b/src/oidmap.h
@@ -43,6 +43,8 @@ GIT_INLINE(khint_t) git_oidmap_hash(const git_oid *oid)
#define git_oidmap_value_at(h, idx) kh_val(h, idx)
#define git_oidmap_delete_at(h, idx) kh_del(oid, h, idx)
+#define git_oidmap_put(h, k, err) kh_put(oid, h, k, err)
+
#define git_oidmap_insert(h, key, val, rval) do { \
khiter_t __pos = kh_put(oid, h, key, &rval); \
if (rval >= 0) { \
diff --git a/src/pack-objects.c b/src/pack-objects.c
index 01286fa56..1604744c3 100644
--- a/src/pack-objects.c
+++ b/src/pack-objects.c
@@ -199,7 +199,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);
+ pos = git_oidmap_put(pb->object_ix, &po->id, &ret);
git_oidmap_value_at(pb->object_ix, pos) = po;
}
}
@@ -246,7 +246,7 @@ int git_packbuilder_insert(git_packbuilder *pb, const git_oid *oid,
git_oid_cpy(&po->id, oid);
po->hash = name_hash(name);
- pos = kh_put(oid, pb->object_ix, &po->id, &ret);
+ pos = git_oidmap_put(pb->object_ix, &po->id, &ret);
if (ret < 0) {
giterr_set_oom();
return ret;
diff --git a/src/pack.c b/src/pack.c
index fe4a65c53..857d26639 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -169,7 +169,7 @@ static int cache_add(
while (cache->memory_used + base->len > cache->memory_limit)
free_lowest_entry(cache);
- k = kh_put(off, cache->entries, offset, &error);
+ k = git_offmap_put(cache->entries, offset, &error);
assert(error != 0);
git_oidmap_value_at(cache->entries, k) = entry;
cache->memory_used += entry->raw.len;
diff --git a/src/revwalk.c b/src/revwalk.c
index 32a4ff906..6581d7a37 100644
--- a/src/revwalk.c
+++ b/src/revwalk.c
@@ -35,7 +35,7 @@ git_commit_list_node *git_revwalk__commit_lookup(
git_oid_cpy(&commit->oid, oid);
- pos = kh_put(oid, walk->commits, &commit->oid, &ret);
+ pos = git_oidmap_put(walk->commits, &commit->oid, &ret);
assert(ret != 0);
git_oidmap_value_at(walk->commits, pos) = commit;
diff --git a/src/sortedcache.c b/src/sortedcache.c
index 199fa2484..e9e50636b 100644
--- a/src/sortedcache.c
+++ b/src/sortedcache.c
@@ -294,7 +294,7 @@ int git_sortedcache_upsert(void **out, git_sortedcache *sc, const char *key)
item_key = ((char *)item) + sc->item_path_offset;
memcpy(item_key, key, keylen);
- pos = kh_put(str, sc->map, item_key, &error);
+ pos = git_strmap_put(sc->map, item_key, &error);
if (error < 0)
goto done;
diff --git a/src/strmap.h b/src/strmap.h
index 9fdab95bb..4c5f888ae 100644
--- a/src/strmap.h
+++ b/src/strmap.h
@@ -42,6 +42,8 @@ typedef khiter_t git_strmap_iter;
#define git_strmap_set_value_at(h, idx, v) kh_val(h, idx) = v
#define git_strmap_delete_at(h, idx) kh_del(str, h, idx)
+#define git_strmap_put(h, k, err) kh_put(str, h, k, err)
+
#define git_strmap_insert(h, key, val, rval) do { \
khiter_t __pos = kh_put(str, h, key, &rval); \
if (rval >= 0) { \
diff --git a/src/submodule.c b/src/submodule.c
index 0bc25cc29..f922518b3 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -329,7 +329,7 @@ static int submodule_get_or_create(git_submodule **out, git_repository *repo, gi
if ((error = submodule_alloc(&sm, repo, name)) < 0)
return error;
- pos = kh_put(str, map, sm->name, &error);
+ pos = git_strmap_put(map, sm->name, &error);
/* nobody can beat us to adding it */
assert(error != 0);
if (error < 0) {
diff --git a/tests/core/oidmap.c b/tests/core/oidmap.c
index 61d75e9d1..88db692fc 100644
--- a/tests/core/oidmap.c
+++ b/tests/core/oidmap.c
@@ -36,7 +36,7 @@ void test_core_oidmap__basic(void)
pos = git_oidmap_lookup_index(map, &items[i].oid);
cl_assert(!git_oidmap_valid_index(map, pos));
- pos = kh_put(oid, map, &items[i].oid, &ret);
+ pos = git_oidmap_put(map, &items[i].oid, &ret);
cl_assert(ret != 0);
git_oidmap_value_at(map, pos) = &items[i];
@@ -90,7 +90,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));
- pos = kh_put(oid, map, &items[i].oid, &ret);
+ pos = git_oidmap_put(map, &items[i].oid, &ret);
cl_assert(ret != 0);
git_oidmap_value_at(map, pos) = &items[i];