summaryrefslogtreecommitdiff
path: root/src/mwindow.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-08-03 17:01:48 -0400
committerEdward Thomson <ethomson@github.com>2016-08-04 10:30:48 -0400
commit2381d9e4900050f879cedf851c0329440db7c5e3 (patch)
tree051781359c05e5f490e8030d8ef7d8da5729fe68 /src/mwindow.c
parent152efee20b74ea261cf8e05410a110687e17376e (diff)
downloadlibgit2-ethomson/mwindow_init.tar.gz
mwindow: init mwindow files in git_libgit2_initethomson/mwindow_init
Diffstat (limited to 'src/mwindow.c')
-rw-r--r--src/mwindow.c27
1 files changed, 8 insertions, 19 deletions
diff --git a/src/mwindow.c b/src/mwindow.c
index d3e9be78b..8a5b5caee 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -33,25 +33,20 @@ static git_mwindow_ctl mem_ctl;
/* Global list of mwindow files, to open packs once across repos */
git_strmap *git__pack_cache = NULL;
-/**
- * Run under mwindow lock
- */
-int git_mwindow_files_init(void)
+static void git_mwindow_files_free(void)
{
- if (git__pack_cache)
- return 0;
-
- git__on_shutdown(git_mwindow_files_free);
+ git_strmap *tmp = git__pack_cache;
- return git_strmap_alloc(&git__pack_cache);
+ git__pack_cache = NULL;
+ git_strmap_free(tmp);
}
-void git_mwindow_files_free(void)
+int git_mwindow_global_init(void)
{
- git_strmap *tmp = git__pack_cache;
+ assert(!git__pack_cache);
- git__pack_cache = NULL;
- git_strmap_free(tmp);
+ git__on_shutdown(git_mwindow_files_free);
+ return git_strmap_alloc(&git__pack_cache);
}
int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
@@ -69,12 +64,6 @@ int git_mwindow_get_pack(struct git_pack_file **out, const char *path)
return -1;
}
- if (git_mwindow_files_init() < 0) {
- git_mutex_unlock(&git__mwindow_mutex);
- git__free(packname);
- return -1;
- }
-
pos = git_strmap_lookup_index(git__pack_cache, packname);
git__free(packname);