From: Derrick Stolee Date: Fri, 24 Jul 2020 12:23:03 GMT Subject: Re: [PATCH v2 04/18] maintenance: initialize task array Message-ID: <1501583a-0fb0-ad88-bd2f-4f64c3c66980@gmail.com> In-Reply-To: On 7/23/2020 3:57 PM, Junio C Hamano wrote: > "Derrick Stolee via GitGitGadget" writes: > >> +static void initialize_tasks(void) >> +{ >> + int i; >> + num_tasks = 0; >> + >> + for (i = 0; i < MAX_NUM_TASKS; i++) >> + tasks[i] = xcalloc(1, sizeof(struct maintenance_task)); >> + >> + tasks[num_tasks]->name = "gc"; >> + tasks[num_tasks]->fn = maintenance_task_gc; >> + tasks[num_tasks]->enabled = 1; >> + num_tasks++; > > Are we going to have 47 different tasks initialized by code like > this in the future? I would have expected that you'd have a table > of tasks that serves as the blueprint copy and copy it to the table > to be used if there is some need to mutate the table-to-be-used. Making it a table will likely make it easier to read. I hadn't thought of it. At the start, I thought that the diff would look awful as we add members to the struct. However, the members that are not specified are set to zero, so I should be able to craft this into something not too terrible. Thanks, -Stolee