Refcounting
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
diff --git a/src/refdb.c b/src/refdb.c
index d8daa77..359842e 100644
--- a/src/refdb.c
+++ b/src/refdb.c
@@ -86,7 +86,7 @@ int git_refdb_compress(git_refdb *db)
return 0;
}
-static void refdb_free(git_refdb *db)
+void git_refdb__free(git_refdb *db)
{
refdb_free_backend(db);
git__free(db);
@@ -97,7 +97,7 @@ void git_refdb_free(git_refdb *db)
if (db == NULL)
return;
- GIT_REFCOUNT_DEC(db, refdb_free);
+ GIT_REFCOUNT_DEC(db, git_refdb__free);
}
int git_refdb_exists(int *exists, git_refdb *refdb, const char *ref_name)
@@ -161,7 +161,7 @@ int git_refdb_iterator_next_name(const char **out, git_reference_iterator *iter)
void git_refdb_iterator_free(git_reference_iterator *iter)
{
- GIT_REFCOUNT_DEC(iter->db, refdb_free);
+ GIT_REFCOUNT_DEC(iter->db, git_refdb__free);
iter->free(iter);
}
diff --git a/src/refdb.h b/src/refdb.h
index 62068db..3aea37b 100644
--- a/src/refdb.h
+++ b/src/refdb.h
@@ -16,6 +16,8 @@ struct git_refdb {
git_refdb_backend *backend;
};
+void git_refdb__free(git_refdb *db);
+
int git_refdb_exists(
int *exists,
git_refdb *refdb,
diff --git a/src/refs.c b/src/refs.c
index c60e042..7103dec 100644
--- a/src/refs.c
+++ b/src/refs.c
@@ -95,6 +95,9 @@ void git_reference_free(git_reference *reference)
if (reference->type == GIT_REF_SYMBOLIC)
git__free(reference->target.symbolic);
+ if (reference->db)
+ GIT_REFCOUNT_DEC(reference->db, git_refdb__free);
+
git__free(reference);
}