Re: [PATCH 059/194] refs: store the main ref store inside the repository struct
- From
Stefan Beller <sbeller@google.com>
- Date
- Feb 6, 2018, 18:01 UTC
- Message-ID
- <CAGZ79kZYZfb1cWX1oeJ6=X6HGs9tCVHik4gs8n7j8WjGKjkK-g@mail.gmail.com>
- In-Reply-To
- <CAPig+cTnucxCf5=24UBKGU5q_n0mwn0eB1pCLdiA77qXn-1n7Q@mail.gmail.com>
On Mon, Feb 5, 2018 at 8:27 PM, Eric Sunshine <sunshine@sunshineco.com> wrote:
Show 19 quoted lines
> On Mon, Feb 5, 2018 at 6:55 PM, Stefan Beller <sbeller@google.com> wrote:
>> diff --git a/refs.c b/refs.c
>> @@ -1609,9 +1609,6 @@ static struct ref_store_hash_entry *alloc_ref_store_hash_entry(
>> -/* A pointer to the ref_store for the main repository: */
>> -static struct ref_store *main_ref_store;
>> diff --git a/repository.h b/repository.h
>> @@ -33,6 +33,11 @@ struct repository {
>> */
>> struct object_store objects;
>>
>> + /*
>> + * The store in which the refs are hold.
>> + */
>> + struct ref_store *main_ref_store;
>
> Do items moved to the 'repository' structure need to be freed when the
> 'repository' itself is freed? Is that being done by a different patch?
> If so, it would ease review burden for the freeing to happen in the
> same patch in which the item is moved to the 'repository'.There are two cases:
* the_repository In the_repository we'll mostly have the globals as they exist (the_index, the_hash_algo, the_ref_store) and just as before these globals will not be freed at the end of the program. * arbitrary repos: For arbitrary repos, we usually need to allocate memory in repo_init and clear it out in repo_free/clear
This patch is incomplete and is leaking the main ref store for arbitrary repos.
Thanks for spotting the mem leak! Stefan