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>
This commit is contained in:

committed by
Junio C Hamano

parent
ed93ea1602
commit
71c871b48d
@ -529,6 +529,10 @@ struct ref_store;
|
||||
typedef struct ref_store *ref_store_init_fn(struct repository *repo,
|
||||
const char *gitdir,
|
||||
unsigned int flags);
|
||||
/*
|
||||
* Release all memory and resources associated with the ref store.
|
||||
*/
|
||||
typedef void ref_store_release_fn(struct ref_store *refs);
|
||||
|
||||
typedef int ref_store_create_on_disk_fn(struct ref_store *refs,
|
||||
int flags,
|
||||
@ -668,6 +672,7 @@ typedef int read_symbolic_ref_fn(struct ref_store *ref_store, const char *refnam
|
||||
struct ref_storage_be {
|
||||
const char *name;
|
||||
ref_store_init_fn *init;
|
||||
ref_store_release_fn *release;
|
||||
ref_store_create_on_disk_fn *create_on_disk;
|
||||
|
||||
ref_transaction_prepare_fn *transaction_prepare;
|
||||
|
Reference in New Issue
Block a user