khash: avoid using `kh_size` directly
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
diff --git a/src/cache.c b/src/cache.c
index 16ae9b3..e8fd207 100644
--- a/src/cache.c
+++ b/src/cache.c
@@ -47,11 +47,11 @@ void git_cache_dump_stats(git_cache *cache)
{
git_cached_obj *object;
- if (kh_size(cache->map) == 0)
+ if (git_cache_size(cache) == 0)
return;
- printf("Cache %p: %d items cached, %"PRIdZ" bytes\n",
- cache, kh_size(cache->map), cache->used_memory);
+ printf("Cache %p: %"PRIuZ" items cached, %"PRIdZ" bytes\n",
+ cache, git_cache_size(cache), cache->used_memory);
kh_foreach_value(cache->map, object, {
char oid_str[9];
@@ -81,7 +81,7 @@ static void clear_cache(git_cache *cache)
{
git_cached_obj *evict = NULL;
- if (kh_size(cache->map) == 0)
+ if (git_cache_size(cache) == 0)
return;
kh_foreach_value(cache->map, evict, {
@@ -119,7 +119,7 @@ static void cache_evict_entries(git_cache *cache)
ssize_t evicted_memory = 0;
/* do not infinite loop if there's not enough entries to evict */
- if (evict_count > kh_size(cache->map)) {
+ if (evict_count > git_cache_size(cache)) {
clear_cache(cache);
return;
}
diff --git a/src/cache.h b/src/cache.h
index 6971237..0f0bfcf 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -53,7 +53,7 @@ void *git_cache_get_any(git_cache *cache, const git_oid *oid);
GIT_INLINE(size_t) git_cache_size(git_cache *cache)
{
- return (size_t)kh_size(cache->map);
+ return (size_t)git_oidmap_size(cache->map);
}
GIT_INLINE(void) git_cached_obj_incref(void *_obj)
diff --git a/src/submodule.c b/src/submodule.c
index 3007d25..0bc25cc 100644
--- a/src/submodule.c
+++ b/src/submodule.c
@@ -555,7 +555,7 @@ int git_submodule_foreach(
goto done;
if (!(error = git_vector_init(
- &snapshot, kh_size(submodules), submodule_cmp))) {
+ &snapshot, git_strmap_num_entries(submodules), submodule_cmp))) {
git_strmap_foreach_value(submodules, sm, {
if ((error = git_vector_insert(&snapshot, sm)) < 0)