Free temporary arrays

This commit is contained in:
Ramana Kumar 2022-09-17 18:21:56 +01:00
parent dcf68949b3
commit f7053514b3
No known key found for this signature in database
GPG Key ID: ED471C788B900433

View File

@ -103,7 +103,7 @@ void eval_poly(fr_t *out, const poly *p, const fr_t *x) {
} }
/** /**
* Evaluate a polynomial in Lagrange formover the finite field at a point. * Evaluate a polynomial in Lagrange form over the finite field at a point.
* *
* @param[out] out The value of the polynomial at the point @p x * @param[out] out The value of the polynomial at the point @p x
* @param[in] p The polynomial in Lagrange form * @param[in] p The polynomial in Lagrange form
@ -119,6 +119,8 @@ C_KZG_RET eval_poly_l(fr_t *out, const poly_l *p, const fr_t *x, const FFTSettin
for (i = 0; i < p->length; i++) { for (i = 0; i < p->length; i++) {
if (fr_equal(x, &fs->expanded_roots_of_unity[i * stride])) { if (fr_equal(x, &fs->expanded_roots_of_unity[i * stride])) {
*out = p->values[i]; *out = p->values[i];
free(inverses_in);
free(inverses);
return C_KZG_OK; return C_KZG_OK;
} }
fr_sub(&inverses_in[i], x, &fs->expanded_roots_of_unity[i * stride]); fr_sub(&inverses_in[i], x, &fs->expanded_roots_of_unity[i * stride]);
@ -137,6 +139,9 @@ C_KZG_RET eval_poly_l(fr_t *out, const poly_l *p, const fr_t *x, const FFTSettin
fr_sub(&tmp, &tmp, &fr_one); fr_sub(&tmp, &tmp, &fr_one);
fr_mul(out, out, &tmp); fr_mul(out, out, &tmp);
free(inverses_in);
free(inverses);
return C_KZG_OK; return C_KZG_OK;
} }