aboutsummaryrefslogtreecommitdiff
path: root/src/math
diff options
context:
space:
mode:
authorJ08nY2017-04-05 16:27:02 +0200
committerJ08nY2017-04-05 16:27:02 +0200
commit9718963a643f0ae15120ceea2d26899892ab1ed4 (patch)
tree0987ce122d298d60aa7d637b84583ce42abf6658 /src/math
parent605049a142aff150d36711c66935c80875e84e36 (diff)
downloadecgen-9718963a643f0ae15120ceea2d26899892ab1ed4.tar.gz
ecgen-9718963a643f0ae15120ceea2d26899892ab1ed4.tar.zst
ecgen-9718963a643f0ae15120ceea2d26899892ab1ed4.zip
Fix some leaks, add option to specify PARI stack size
Diffstat (limited to 'src/math')
-rw-r--r--src/math/curve.c1
-rw-r--r--src/math/field.c2
-rw-r--r--src/math/random.c2
3 files changed, 3 insertions, 2 deletions
diff --git a/src/math/curve.c b/src/math/curve.c
index 6b0742c..1703f78 100644
--- a/src/math/curve.c
+++ b/src/math/curve.c
@@ -41,6 +41,7 @@ curve_t *curve_copy(curve_t *src, curve_t *dest) {
void curve_free(curve_t **curve) {
if (*curve) {
seed_free(&(*curve)->seed);
+ points_free_deep(&(*curve)->generators, (*curve)->ngens);
points_free_deep(&(*curve)->points, (*curve)->npoints);
pari_free(*curve);
*curve = NULL;
diff --git a/src/math/field.c b/src/math/field.c
index 3774040..cc3656f 100644
--- a/src/math/field.c
+++ b/src/math/field.c
@@ -128,7 +128,7 @@ GEN field_params(GEN field) {
gel(out, j) = stoi(i);
j++;
}
- if (gc_needed(btop, 1)) gerepileall(btop, 2, &out, &c);
+ gerepileall(btop, 2, &out, &c);
}
}
return gerepilecopy(ltop, out);
diff --git a/src/math/random.c b/src/math/random.c
index a1d88ab..20098e1 100644
--- a/src/math/random.c
+++ b/src/math/random.c
@@ -47,7 +47,7 @@ GEN random_prime(long bits) {
pari_sp btop = avma;
do {
p = randomprime(range);
- if (gc_needed(btop, 1)) p = gerepilecopy(btop, p);
+ p = gerepileupto(btop, p);
} while (!isprime(p));
}