]> git.proxmox.com Git - libgit2.git/blobdiff - src/cache.h
I broke your bindings
[libgit2.git] / src / cache.h
index 9f525e68c3134e0ee8b7f36c027aea7ae048b0ef..975aaff7e86d4e707296a2b875aff80f5fc9e7bc 100644 (file)
@@ -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