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);
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
const char *path,
bool local);
-/* Free the object source and release all associated resources. */
-void odb_source_files_free(struct odb_source_files *files);
-
/*
* Cast the given object database source to the files backend. This will cause
* a BUG in case the source doesn't use this backend.
void odb_source_free(struct odb_source *source)
{
- struct odb_source_files *files;
if (!source)
return;
- files = odb_source_files_downcast(source);
- odb_source_files_free(files);
+ source->free(source);
}
void odb_source_release(struct odb_source *source)
* the current working directory.
*/
char *path;
+
+ /*
+ * This callback is expected to free the underlying object database source and
+ * all associated resources. The function will never be called with a NULL pointer.
+ */
+ void (*free)(struct odb_source *source);
};
/*