aboutsummaryrefslogtreecommitdiffstats
path: root/refs/debug.c
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2024-05-17 10:18:24 +0200
committerJunio C Hamano <gitster@pobox.com>2024-05-17 10:33:37 -0700
commit71c871b48dfaf300ca20e205917db72ab9c6d7b3 (patch)
tree6b8c0fc18c2816d38e7c554c9f7d90e975a034bc /refs/debug.c
parentrefs: rename `init_db` callback to avoid confusion (diff)
downloadgit-71c871b48dfaf300ca20e205917db72ab9c6d7b3.tar.gz
git-71c871b48dfaf300ca20e205917db72ab9c6d7b3.zip
refs: implement releasing ref storages
Ref storages are typically only initialized once for `the_repository` and then never released. Until now we got away with that without causing memory leaks because `the_repository` stays reachable, and because the ref backend is reachable via `the_repository` its memory basically never leaks. This is about to change though because of the upcoming migration logic, which will create a secondary ref storage. In that case, we will either have to release the old or new ref storage to avoid leaks. Implement a new `release` callback and expose it via a new `ref_storage_release()` function. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'refs/debug.c')
-rw-r--r--refs/debug.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/refs/debug.c b/refs/debug.c
index 4cc4910974..3a063077ba 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -33,6 +33,13 @@ struct ref_store *maybe_debug_wrap_ref_store(const char *gitdir, struct ref_stor
return (struct ref_store *)res;
}
+static void debug_release(struct ref_store *refs)
+{
+ struct debug_ref_store *drefs = (struct debug_ref_store *)refs;
+ drefs->refs->be->release(drefs->refs);
+ trace_printf_key(&trace_refs, "release\n");
+}
+
static int debug_create_on_disk(struct ref_store *refs, int flags, struct strbuf *err)
{
struct debug_ref_store *drefs = (struct debug_ref_store *)refs;
@@ -427,6 +434,7 @@ static int debug_reflog_expire(struct ref_store *ref_store, const char *refname,
struct ref_storage_be refs_be_debug = {
.name = "debug",
.init = NULL,
+ .release = debug_release,
.create_on_disk = debug_create_on_disk,
/*