File tree Expand file tree Collapse file tree 3 files changed +21
-15
lines changed
Expand file tree Collapse file tree 3 files changed +21
-15
lines changed Original file line number Diff line number Diff line change 1010#include "allocators/stdalloc.h"
1111#include "allocators/win32_crtdbg.h"
1212
13+ #if defined(GIT_MSVC_CRTDBG )
14+ # include "win32/w32_stack.h"
15+ # include "win32/w32_crtdbg_stacktrace.h"
16+ #endif
17+
1318git_allocator git__allocator ;
1419
1520static int setup_default_allocator (void )
@@ -21,8 +26,23 @@ static int setup_default_allocator(void)
2126#endif
2227}
2328
29+ #if defined(GIT_MSVC_CRTDBG )
30+ static void allocator_global_shutdown (void )
31+ {
32+ git_win32__crtdbg_stacktrace_cleanup ();
33+ git_win32__stack_cleanup ();
34+ }
35+ #endif
36+
2437int git_allocator_global_init (void )
2538{
39+ #if defined(GIT_MSVC_CRTDBG )
40+ git_win32__crtdbg_stacktrace_init ();
41+ git_win32__stack_init ();
42+
43+ git__on_shutdown (allocator_global_shutdown );
44+ #endif
45+
2646 /*
2747 * We don't want to overwrite any allocator which has been set before
2848 * the init function is called.
Original file line number Diff line number Diff line change 99
1010#if defined(GIT_MSVC_CRTDBG )
1111
12+ #include "win32/w32_stack.h"
1213#include "win32/w32_crtdbg_stacktrace.h"
1314
1415static void * crtdbg__malloc (size_t len , const char * file , int line )
Original file line number Diff line number Diff line change 1919#include "thread-utils.h"
2020#include "git2/global.h"
2121#include "transports/ssh.h"
22-
23- #if defined(GIT_MSVC_CRTDBG )
2422#include "win32/w32_stack.h"
25- #include "win32/w32_crtdbg_stacktrace.h"
26- #endif
2723
2824git_mutex git__mwindow_mutex ;
2925
@@ -72,12 +68,6 @@ static int init_common(void)
7268 size_t i ;
7369 int ret ;
7470
75- /* Initialize the CRT debug allocator first, before our first malloc */
76- #if defined(GIT_MSVC_CRTDBG )
77- git_win32__crtdbg_stacktrace_init ();
78- git_win32__stack_init ();
79- #endif
80-
8171 /* Initialize subsystems that have global state */
8272 for (i = 0 ; i < ARRAY_SIZE (git__init_callbacks ); i ++ )
8373 if ((ret = git__init_callbacks [i ]()) != 0 )
@@ -200,11 +190,6 @@ int git_libgit2_shutdown(void)
200190
201191 FlsFree (_fls_index );
202192 git_mutex_free (& git__mwindow_mutex );
203-
204- #if defined(GIT_MSVC_CRTDBG )
205- git_win32__crtdbg_stacktrace_cleanup ();
206- git_win32__stack_cleanup ();
207- #endif
208193 }
209194
210195 /* Exit the lock */
You can’t perform that action at this time.
0 commit comments