| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
/* |
|
2
|
|
|
|
|
|
|
* Copyright (C) the libgit2 contributors. All rights reserved. |
|
3
|
|
|
|
|
|
|
* |
|
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. |
|
6
|
|
|
|
|
|
|
*/ |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#include "alloc.h" |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#include "allocators/stdalloc.h" |
|
11
|
|
|
|
|
|
|
#include "allocators/win32_crtdbg.h" |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
git_allocator git__allocator; |
|
14
|
|
|
|
|
|
|
|
|
15
|
86
|
|
|
|
|
|
static int setup_default_allocator(void) |
|
16
|
|
|
|
|
|
|
{ |
|
17
|
|
|
|
|
|
|
#if defined(GIT_MSVC_CRTDBG) |
|
18
|
|
|
|
|
|
|
return git_win32_crtdbg_init_allocator(&git__allocator); |
|
19
|
|
|
|
|
|
|
#else |
|
20
|
86
|
|
|
|
|
|
return git_stdalloc_init_allocator(&git__allocator); |
|
21
|
|
|
|
|
|
|
#endif |
|
22
|
|
|
|
|
|
|
} |
|
23
|
|
|
|
|
|
|
|
|
24
|
86
|
|
|
|
|
|
int git_allocator_global_init(void) |
|
25
|
|
|
|
|
|
|
{ |
|
26
|
|
|
|
|
|
|
/* |
|
27
|
|
|
|
|
|
|
* We don't want to overwrite any allocator which has been set before |
|
28
|
|
|
|
|
|
|
* the init function is called. |
|
29
|
|
|
|
|
|
|
*/ |
|
30
|
86
|
50
|
|
|
|
|
if (git__allocator.gmalloc != NULL) |
|
31
|
0
|
|
|
|
|
|
return 0; |
|
32
|
|
|
|
|
|
|
|
|
33
|
86
|
|
|
|
|
|
return setup_default_allocator(); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
int git_allocator_setup(git_allocator *allocator) |
|
37
|
|
|
|
|
|
|
{ |
|
38
|
0
|
0
|
|
|
|
|
if (!allocator) |
|
39
|
0
|
|
|
|
|
|
return setup_default_allocator(); |
|
40
|
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
memcpy(&git__allocator, allocator, sizeof(*allocator)); |
|
42
|
0
|
|
|
|
|
|
return 0; |
|
43
|
|
|
|
|
|
|
} |