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
|
|
|
|
|
|
|
#ifndef INCLUDE_cache_h__ |
8
|
|
|
|
|
|
|
#define INCLUDE_cache_h__ |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#include "common.h" |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#include "git2/common.h" |
13
|
|
|
|
|
|
|
#include "git2/oid.h" |
14
|
|
|
|
|
|
|
#include "git2/odb.h" |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
#include "thread.h" |
17
|
|
|
|
|
|
|
#include "oidmap.h" |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
enum { |
20
|
|
|
|
|
|
|
GIT_CACHE_STORE_ANY = 0, |
21
|
|
|
|
|
|
|
GIT_CACHE_STORE_RAW = 1, |
22
|
|
|
|
|
|
|
GIT_CACHE_STORE_PARSED = 2 |
23
|
|
|
|
|
|
|
}; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
typedef struct { |
26
|
|
|
|
|
|
|
git_oid oid; |
27
|
|
|
|
|
|
|
int16_t type; /* git_object_t value */ |
28
|
|
|
|
|
|
|
uint16_t flags; /* GIT_CACHE_STORE value */ |
29
|
|
|
|
|
|
|
size_t size; |
30
|
|
|
|
|
|
|
git_atomic32 refcount; |
31
|
|
|
|
|
|
|
} git_cached_obj; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
typedef struct { |
34
|
|
|
|
|
|
|
git_oidmap *map; |
35
|
|
|
|
|
|
|
git_rwlock lock; |
36
|
|
|
|
|
|
|
ssize_t used_memory; |
37
|
|
|
|
|
|
|
} git_cache; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
extern bool git_cache__enabled; |
40
|
|
|
|
|
|
|
extern ssize_t git_cache__max_storage; |
41
|
|
|
|
|
|
|
extern git_atomic_ssize git_cache__current_storage; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
int git_cache_set_max_object_size(git_object_t type, size_t size); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
int git_cache_init(git_cache *cache); |
46
|
|
|
|
|
|
|
void git_cache_dispose(git_cache *cache); |
47
|
|
|
|
|
|
|
void git_cache_clear(git_cache *cache); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
void *git_cache_store_raw(git_cache *cache, git_odb_object *entry); |
50
|
|
|
|
|
|
|
void *git_cache_store_parsed(git_cache *cache, git_object *entry); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
git_odb_object *git_cache_get_raw(git_cache *cache, const git_oid *oid); |
53
|
|
|
|
|
|
|
git_object *git_cache_get_parsed(git_cache *cache, const git_oid *oid); |
54
|
|
|
|
|
|
|
void *git_cache_get_any(git_cache *cache, const git_oid *oid); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
GIT_INLINE(size_t) git_cache_size(git_cache *cache) |
57
|
|
|
|
|
|
|
{ |
58
|
|
|
|
|
|
|
return (size_t)git_oidmap_size(cache->map); |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
101
|
|
|
|
|
|
GIT_INLINE(void) git_cached_obj_incref(void *_obj) |
62
|
|
|
|
|
|
|
{ |
63
|
101
|
|
|
|
|
|
git_cached_obj *obj = _obj; |
64
|
101
|
|
|
|
|
|
git_atomic32_inc(&obj->refcount); |
65
|
101
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
void git_cached_obj_decref(void *_obj); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
#endif |