diff options
Diffstat (limited to 'src/cache.h')
| -rw-r--r-- | src/cache.h | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/cache.h b/src/cache.h index 9f525e68c..975aaff7e 100644 --- a/src/cache.h +++ b/src/cache.h @@ -7,6 +7,8 @@ #include "thread-utils.h" +#define GIT_DEFAULT_CACHE_SIZE 128 + typedef void (*git_cached_obj_freeptr)(void *); typedef struct { @@ -35,4 +37,23 @@ void git_cache_free(git_cache *cache); void *git_cache_try_store(git_cache *cache, void *entry); void *git_cache_get(git_cache *cache, const git_oid *oid); + +GIT_INLINE(int) git_cached_obj_compare(git_cached_obj *obj, const git_oid *oid) +{ + return git_oid_cmp(&obj->oid, oid); +} + +GIT_INLINE(void) git_cached_obj_incref(git_cached_obj *obj) +{ + git_atomic_inc(&obj->refcount); +} + +GIT_INLINE(void) git_cached_obj_decref(git_cached_obj *obj, git_cached_obj_freeptr free_obj) +{ + if (git_atomic_dec(&obj->refcount) == 0) + free_obj(obj); +} + + + #endif |
