From: Derrick Stolee Date: Thu, 12 Jan 2023 15:21:15 GMT Subject: Re: [PATCH v2 5/6] cache API: add a "INDEX_STATE_INIT" macro/function, add release_index() Message-ID: <270ef93c-cfdc-d119-5740-f704d7f2a029@github.com> In-Reply-To: On 1/12/2023 7:55 AM, Ævar Arnfjörð Bjarmason wrote: > As we'll see in a subsequent commit we'll get advantages from always > initializing the "repo" member of the "struct index_state". To make > that easier let's introduce an initialization macro & function. > > The various ad-hoc initialization of the structure can then be changed > over to it, and we can remove the various "0" assignments in > discard_index() in favor of calling index_state_init() at the end. > - memset(&o->result, 0, sizeof(o->result)); > + index_state_init(&o->result); > o->result.initialized = 1; It's interesting that 'struct index_state' has an 'initialized' member that we aren't setting in index_state_init(). Perhaps it's only being used in special cases like this, and means something more specific than "index_state_init() was run"? Or maybe we could add it to INDEX_STATE_INIT and drop this line? Thanks, -Stolee