diff options
| author | Russell Belfer <rb@github.com> | 2013-09-11 12:45:20 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-09-17 09:31:45 -0700 |
| commit | a3aa5f4d5dcbe038f1d1c5ff40eed29d27953fbe (patch) | |
| tree | 6ef7a6b5bdfc26e10279c2629f58036f4025f199 /src/hash/hash_win32.c | |
| parent | e7d0ced2192c5efeea6d9f5667d366891010b86a (diff) | |
| download | libgit2-a3aa5f4d5dcbe038f1d1c5ff40eed29d27953fbe.tar.gz | |
Add simple global shutdown hooks
Increasingly there are a number of components that want to do some
cleanup at global shutdown time (at least if there are not going
to be memory leaks). This creates a very simple system of shutdown
hooks that will be invoked by git_threads_shutdown. Right now, the
maximum number of hooks is hardcoded, but since adding a hook is
not a public API, it should be fine and I thought it was better to
start off with really simple code.
Diffstat (limited to 'src/hash/hash_win32.c')
| -rw-r--r-- | src/hash/hash_win32.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/hash/hash_win32.c b/src/hash/hash_win32.c index 095ceb359..bb2231364 100644 --- a/src/hash/hash_win32.c +++ b/src/hash/hash_win32.c @@ -89,7 +89,15 @@ GIT_INLINE(void) hash_cryptoapi_prov_shutdown(void) hash_prov.type = INVALID; } -int git_hash_global_init() +static void git_hash_global_shutdown(void) +{ + if (hash_prov.type == CNG) + hash_cng_prov_shutdown(); + else if(hash_prov.type == CRYPTOAPI) + hash_cryptoapi_prov_shutdown(); +} + +int git_hash_global_init(void) { int error = 0; @@ -99,15 +107,9 @@ int git_hash_global_init() if ((error = hash_cng_prov_init()) < 0) error = hash_cryptoapi_prov_init(); - return error; -} + git__on_shutdown(git_hash_global_shutdown); -void git_hash_global_shutdown() -{ - if (hash_prov.type == CNG) - hash_cng_prov_shutdown(); - else if(hash_prov.type == CRYPTOAPI) - hash_cryptoapi_prov_shutdown(); + return error; } /* CryptoAPI: available in Windows XP and newer */ |
