diff options
| author | J08nY | 2017-02-28 19:14:48 +0100 |
|---|---|---|
| committer | J08nY | 2017-02-28 19:14:48 +0100 |
| commit | 209655dad1eda390213b9b9b53d3c56ae6dc493b (patch) | |
| tree | 84cba0fb750d95cc5f8a74d1297e770da2343593 /src/math | |
| parent | c1730ad531219bcfbefe5ed7525c9862ee6af281 (diff) | |
| download | ecgen-209655dad1eda390213b9b9b53d3c56ae6dc493b.tar.gz ecgen-209655dad1eda390213b9b9b53d3c56ae6dc493b.tar.zst ecgen-209655dad1eda390213b9b9b53d3c56ae6dc493b.zip | |
fixed leak in gens and points
Diffstat (limited to 'src/math')
| -rw-r--r-- | src/math/gens.c | 2 | ||||
| -rw-r--r-- | src/math/point.c | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/math/gens.c b/src/math/gens.c index f211a82..93106b7 100644 --- a/src/math/gens.c +++ b/src/math/gens.c @@ -6,6 +6,8 @@ #include "point.h" int gens_put(curve_t *curve, GEN generators, long len) { + points_free_deep(&curve->generators, curve->ngens); + curve->generators = points_new((size_t)len); curve->ngens = (size_t)len; diff --git a/src/math/point.c b/src/math/point.c index d6e8858..8505954 100644 --- a/src/math/point.c +++ b/src/math/point.c @@ -62,6 +62,8 @@ void points_free_deep(point_t ***points, size_t npoints) { } int point_random(curve_t *curve, config_t *config, arg_t *args) { + points_free_deep(&curve->points, curve->npoints); + point_t *p = point_new(); p->point = genrand(curve->curve); p->order = ellorder(curve->curve, p->point, NULL); @@ -77,6 +79,8 @@ int points_random(curve_t *curve, config_t *config, arg_t *args) { fprintf(stderr, "No args to an arged function. points_random"); return INT_MIN; } + points_free_deep(&curve->points, curve->npoints); + size_t npoints = *(size_t *)args->args; curve->points = points_new(npoints); @@ -112,6 +116,8 @@ int points_primet(curve_t *curve, config_t *config, arg_t *args) { fprintf(stderr, "No args to an arged function. points_primet"); return INT_MIN; } + points_free_deep(&curve->points, curve->npoints); + pari_ulong *primes = (pari_ulong *)args->args; size_t nprimes = args->nargs; @@ -145,6 +151,8 @@ int points_primet(curve_t *curve, config_t *config, arg_t *args) { int points_prime(curve_t *curve, config_t *config, arg_t *args) { // TODO stack code!!! + points_free_deep(&curve->points, curve->npoints); + GEN factors = Z_factor(curve->order); GEN primes = gel(factors, 1); long nprimes = glength(primes); |
