diff options
| author | Russell Belfer <rb@github.com> | 2013-12-12 12:11:38 -0800 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-12-12 12:11:38 -0800 |
| commit | 9cfce2735d77f4d8b6005e62349dd97c0c6de5ab (patch) | |
| tree | b538c09a7d7d6285f218a052019332ac02bb314c /src/fileops.c | |
| parent | 11bd7a034ba9046a7ba601c446e937377d507065 (diff) | |
| download | libgit2-9cfce2735d77f4d8b6005e62349dd97c0c6de5ab.tar.gz | |
Cleanups, renames, and leak fixes
This renames git_vector_free_all to the better git_vector_free_deep
and also contains a couple of memory leak fixes based on valgrind
checks. The fixes are specifically: failure to free global dir
path variables when not compiled with threading on and failure to
free filters from the filter registry that had not be initialized
fully.
Diffstat (limited to 'src/fileops.c')
| -rw-r--r-- | src/fileops.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/fileops.c b/src/fileops.c index 98dcd3269..a60689f3f 100644 --- a/src/fileops.c +++ b/src/fileops.c @@ -615,6 +615,8 @@ static git_futils_dirs_guess_cb git_futils__dir_guess[GIT_FUTILS_DIR__MAX] = { git_futils_guess_template_dirs, }; +static int git_futils__dirs_shutdown_set = 0; + void git_futils_dirs_global_shutdown(void) { int i; @@ -631,8 +633,6 @@ int git_futils_dirs_global_init(void) for (i = 0; !error && i < GIT_FUTILS_DIR__MAX; i++) error = git_futils_dirs_get(&path, i); - git__on_shutdown(git_futils_dirs_global_shutdown); - return error; } @@ -652,9 +652,16 @@ int git_futils_dirs_get(const git_buf **out, git_futils_dir_t which) GITERR_CHECK_ERROR(git_futils_check_selector(which)); - if (!git_buf_len(&git_futils__dirs[which])) + if (!git_buf_len(&git_futils__dirs[which])) { + /* prepare shutdown if we're going to need it */ + if (!git_futils__dirs_shutdown_set) { + git__on_shutdown(git_futils_dirs_global_shutdown); + git_futils__dirs_shutdown_set = 1; + } + GITERR_CHECK_ERROR( git_futils__dir_guess[which](&git_futils__dirs[which])); + } *out = &git_futils__dirs[which]; return 0; |
