On Thu, Feb 16, 2023, at 07:26, Michael Paquier wrote:
> Indeed, it is true that any code path of numeric.c that relies on a
> NumericVar with an allocation done in its buffer is careful enough to
> free it, except for generate_series's SRF where one step of the
> computation is done. I don't see directly why you could not do the
> following:
> @@ -11973,6 +11973,9 @@ accum_sum_final(NumericSumAccum *accum,
> NumericVar *result)
> /* And add them together */
> add_var(&pos_var, &neg_var, result);
>
> + free_var(&pos_var);
> + free_var(&neg_var);
> +
Thanks for looking and explaining.
I added the free_var() calls after strip_var() to match the similar existing code at the end of sqrt_var().
Not that it matters, but thought it looked nicer to keep them in the same order.
/Joel