Re: [PATCH v3 15/20] repository: add index_state to struct repo
- From
Stefan Beller <sbeller@google.com>
- Date
- Jun 21, 2017, 23:00 UTC
- Message-ID
- <CAGZ79kaCLO=CVZLtc3BF8WHXPtO06oaa8RmsXYB6kUHU8ty1Rg@mail.gmail.com>
- In-Reply-To
- <20170621225403.GH53348@google.com>
On Wed, Jun 21, 2017 at 3:54 PM, Brandon Williams <bmwill@google.com> wrote:
Show 13 quoted lines
> On 06/21, Jonathan Tan wrote:
>> On Tue, 20 Jun 2017 12:19:46 -0700
>> Brandon Williams <bmwill@google.com> wrote:
>>
>> > +int repo_read_index(struct repository *repo)
>> > +{
>> > + if (!repo->index)
>> > + repo->index = xcalloc(1, sizeof(struct index_state));
>>
>> sizeof(*repo->index)?
>
> Is there a reason to prefer one versus the other? Either way I can
> change.If repo->index changes its type, then we do not need to fix it here strictly. We may fix surrounding code, but not necessarily, e.g. when the type change is a cast to a wider type (subclass so to speak), so e.g. *repo->index is made to be:
struct new_index {
struct index_state index;
int more_state
};then this area of code would just work fine, no maintenance burden.