Subject: Re: [PATCH 6/8] sequencer: simplify allocation of result array in todo_list_rearrange_squash()

From: Oswald Buddenhagen <[email-masked]>
Date: Thu, 23 Mar 2023 23:13:52 +0100

On Thu, Mar 23, 2023 at 07:46:28PM +0000, Phillip Wood wrote:
>> +		assert(nr == todo_list->nr);
>
>If this assert fails we may have already had some out of bounds memory 
>accesses.
>
the loop could have run short, too.
but anyway, this isn't a runtime check, it's an assertion of a loop 
invariant.

>> +		todo_list->alloc = nr;
>>   		FREE_AND_NULL(todo_list->items);
>
>I think it would be cleaner to keep the original ordering and free the 
>old list before assigning todo_list->alloc
>
my reasoning is that it's closer to the assert which also refers to it, 
and it really makes sense to have _that_ first. also, the value is more 
likely to be still in a register at that point.

>>   		todo_list->items = items;
>> -		todo_list->nr = nr;
>> -		todo_list->alloc = alloc;
>>   	}
>