summaryrefslogtreecommitdiff
path: root/src/mwindow.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2018-12-01 08:50:36 +0100
committerPatrick Steinhardt <ps@pks.im>2019-02-15 13:16:48 +0100
commit84a089da3701db370b2c77e6866abe3a5065c542 (patch)
treea70b47efb1c29ab0c779fbb7f25447a33d9d0dce /src/mwindow.c
parent8da93944f3d3c271ea7a2ec035c6ea48654fa71e (diff)
downloadlibgit2-84a089da3701db370b2c77e6866abe3a5065c542.tar.gz
maps: provide return value when deleting entries
Currently, the delete functions of maps do not provide a return value. Like this, it is impossible to tell whether the entry has really been deleted or not. Change the implementation to provide either a return value of zero if the entry has been successfully deleted or `GIT_ENOTFOUND` if the key could not be found. Convert callers to the `delete_at` functions to instead use this higher-level interface.
Diffstat (limited to 'src/mwindow.c')
-rw-r--r--src/mwindow.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/mwindow.c b/src/mwindow.c
index 09e219d7c..949e5fa46 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -94,7 +94,6 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
void git_mwindow_put_pack(struct git_pack_file *pack)
{
int count;
- size_t pos;
if (git_mutex_lock(&git__mwindow_mutex) < 0)
return;
@@ -102,13 +101,12 @@ void git_mwindow_put_pack(struct git_pack_file *pack)
/* put before get would be a corrupted state */
assert(git__pack_cache);
- pos = git_strmap_lookup_index(git__pack_cache, pack->pack_name);
/* if we cannot find it, the state is corrupted */
- assert(git_strmap_valid_index(git__pack_cache, pos));
+ assert(git_strmap_exists(git__pack_cache, pack->pack_name));
count = git_atomic_dec(&pack->refcount);
if (count == 0) {
- git_strmap_delete_at(git__pack_cache, pos);
+ git_strmap_delete(git__pack_cache, pack->pack_name);
git_packfile_free(pack);
}