From 92cb16e8103da998aa1bf226d24ef6771a92c5d5 Mon Sep 17 00:00:00 2001 From: J08nY Date: Thu, 20 Feb 2020 15:06:18 +0100 Subject: Allocate and initialize formula variables only once. --- pyecsca/codegen/templates/point.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'pyecsca/codegen/templates/point.c') diff --git a/pyecsca/codegen/templates/point.c b/pyecsca/codegen/templates/point.c index 445bdc4..aebb7c7 100644 --- a/pyecsca/codegen/templates/point.c +++ b/pyecsca/codegen/templates/point.c @@ -1,12 +1,13 @@ #include "point.h" #include +{% import "ops.c" as ops %} point_t *point_new(void) { point_t *result = malloc(sizeof(point_t)); {%- for variable in variables %} bn_init(&result->{{ variable }}); {%- endfor %} - + result->infinity = false; return result; } @@ -74,7 +75,7 @@ bool point_equals_affine(const point_t *one, const point_t *other, const curve_t } void point_to_affine(const point_t *point, const curve_t *curve, bn_t *out_x, bn_t *out_y) { - {%- include "ops.c" %} + {{ ops.render_all(allocations, initializations, operations, returns, frees) }} {%- if "x" in allocations %} if (out_x) { bn_copy(&x, out_x); -- cgit v1.3.1