vendor/libgit2/src/mwindow.c in rugged-0.25.0b5 vs vendor/libgit2/src/mwindow.c in rugged-0.25.0b6

- old
+ new

@@ -31,29 +31,24 @@ 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_strmap *tmp = git__pack_cache; - git__on_shutdown(git_mwindow_files_free); - - 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) { int error; @@ -64,15 +59,9 @@ if ((error = git_packfile__name(&packname, path)) < 0) return error; if (git_mutex_lock(&git__mwindow_mutex) < 0) { giterr_set(GITERR_OS, "failed to lock mwindow mutex"); - 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);