Re: [PATCH v2 04/18] maintenance: initialize task array
- From
Emily Shaffer <emilyshaffer@google.com>
- Date
- Jul 29, 2020, 22:19 UTC
- Message-ID
- <20200729221939.GB2965447@google.com>
- In-Reply-To
- <8e260bccf1a0b6cd799a6bc78798b31ebed8ad7e.1595527000.git.gitgitgadget@gmail.com>
On Thu, Jul 23, 2020 at 05:56:26PM +0000, Derrick Stolee via GitGitGadget wrote:
Show 7 quoted lines
> +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));[jonathan tan] I wonder why this is an array of pointers, not of objects? If they were objects, we could use an initializer. But in a later commit I see the array is sorted, OK.
Show 5 quoted lines
> + > + tasks[num_tasks]->name = "gc"; > + tasks[num_tasks]->fn = maintenance_task_gc; > + tasks[num_tasks]->enabled = 1; > + num_tasks++;