From 47b965079ddd9ced04810d0a8738a1ca94f02268 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 5 Mar 2026 15:19:46 +0100 Subject: odb/source: make `free()` function pluggable Introduce a new callback function in `struct odb_source` to make the function pluggable. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- odb/source-files.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'odb/source-files.c') diff --git a/odb/source-files.c b/odb/source-files.c index 7496e1d9f8..65d7805c5a 100644 --- a/odb/source-files.c +++ b/odb/source-files.c @@ -18,10 +18,9 @@ static void odb_source_files_reparent(const char *name UNUSED, files->base.path = path; } -void odb_source_files_free(struct odb_source_files *files) +static void odb_source_files_free(struct odb_source *source) { - if (!files) - return; + struct odb_source_files *files = odb_source_files_downcast(source); chdir_notify_unregister(NULL, odb_source_files_reparent, files); odb_source_loose_free(files->loose); packfile_store_free(files->packed); @@ -40,6 +39,8 @@ struct odb_source_files *odb_source_files_new(struct object_database *odb, files->loose = odb_source_loose_new(&files->base); files->packed = packfile_store_new(&files->base); + files->base.free = odb_source_files_free; + /* * Ideally, we would only ever store absolute paths in the source. This * is not (yet) possible though because we access and assume relative -- cgit v1.3