Re: [PATCH v16 Part II 2/8] bisect--helper: `bisect_write` shell function in C
- From
Pranit Bauva <pranit.bauva@gmail.com>
- Date
- Oct 30, 2017, 17:35 UTC
- Message-ID
- <CAFZEwPP7dkWwRJD2ohDfnV_Phb0ga7YPZoVC920JPrQXLAGekw@mail.gmail.com>
- In-Reply-To
- <20171027172845.15437-1-martin.agren@gmail.com>
Hey Martin,
On Fri, Oct 27, 2017 at 10:58 PM, Martin Ågren <martin.agren@gmail.com> wrote:
Show 11 quoted lines
> On 27 October 2017 at 17:06, Pranit Bauva <pranit.bauva@gmail.com> wrote:
>> +static void free_terms(struct bisect_terms *terms)
>> +{
>> + if (!terms->term_good)
>> + free((void *) terms->term_good);
>> + if (!terms->term_bad)
>> + free((void *) terms->term_bad);
>> +}
>
> These look like no-ops. Remove `!` for correctness, or `if (...)` for
> simplicity, since `free()` can handle NULL.I probably forgot to do this here. I will make the change.
Show 8 quoted lines
> You leave the pointers dangling, but you're ok for now since this is the > last thing that happens in `cmd_bisect__helper()`. Your later patches > add more users, but they're also ok, since they immediately assign new > values. > > In case you (and others) find it useful, the below is a patch I've been > sitting on for a while as part of a series to plug various memory-leaks. > `FREE_AND_NULL_CONST()` would be useful in precisely these situations.
Honestly, I wouldn't be the best person to judge this.
Regards, Pranit Bauva