2 * Copyright (C) the libgit2 contributors. All rights reserved.
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
10 #include "allocators/stdalloc.h"
11 #include "allocators/win32_crtdbg.h"
13 git_allocator git__allocator
;
15 static int setup_default_allocator(void)
17 #if defined(GIT_MSVC_CRTDBG)
18 return git_win32_crtdbg_init_allocator(&git__allocator
);
20 return git_stdalloc_init_allocator(&git__allocator
);
24 int git_allocator_global_init(void)
27 * We don't want to overwrite any allocator which has been set before
28 * the init function is called.
30 if (git__allocator
.gmalloc
!= NULL
)
33 return setup_default_allocator();
36 int git_allocator_setup(git_allocator
*allocator
)
39 return setup_default_allocator();
41 memcpy(&git__allocator
, allocator
, sizeof(*allocator
));