diff options
| author | Russell Belfer <rb@github.com> | 2013-04-12 12:44:51 -0700 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2013-04-22 16:50:51 +0200 |
| commit | b12b72ea82776bbbd4296eeac1376055b0487edf (patch) | |
| tree | 193ea7ff5f0a026c6157663cc9e181df3c3da364 /src/cache.h | |
| parent | badd85a61354ef7b62c5f8e53d740738e5ef1e57 (diff) | |
| download | libgit2-b12b72ea82776bbbd4296eeac1376055b0487edf.tar.gz | |
Add range checking around cache opts
Add a git_cache_set_max_object_size method that does more checking
around setting the max object size. Also add a git_cache_size to
read the number of objects currently in the cache. This makes it
easier to write tests.
Diffstat (limited to 'src/cache.h')
| -rw-r--r-- | src/cache.h | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/cache.h b/src/cache.h index 8b2aa1f79..13b630e89 100644 --- a/src/cache.h +++ b/src/cache.h @@ -20,9 +20,6 @@ enum { GIT_CACHE_STORE_PARSED = 2 }; -extern bool git_cache__enabled; -extern size_t git_cache__max_object_size[8]; - typedef struct { git_oid oid; int16_t type; @@ -37,6 +34,10 @@ typedef struct { size_t used_memory; } git_cache; +extern bool git_cache__enabled; + +int git_cache_set_max_object_size(git_otype type, size_t size); + int git_cache_init(git_cache *cache); void git_cache_free(git_cache *cache); @@ -47,6 +48,11 @@ git_odb_object *git_cache_get_raw(git_cache *cache, const git_oid *oid); git_object *git_cache_get_parsed(git_cache *cache, const git_oid *oid); void *git_cache_get_any(git_cache *cache, const git_oid *oid); +GIT_INLINE(size_t) git_cache_size(git_cache *cache) +{ + return (size_t)kh_size(cache->map); +} + GIT_INLINE(void) git_cached_obj_incref(void *_obj) { git_cached_obj *obj = _obj; |
