ref: efd8d6c0a0f1084963da444bc26126efe8918d63
parent: 3c5b2aa9bb8dd8d34e9cce4006d31ae81cfe9d2c
author: Sigrid Solveig Haflínudóttir <sigrid@ftrv.se>
date: Thu Jan 2 15:02:34 EST 2025
libmp test: fix the memory leaks
--- a/3rd/mp/test.c
+++ b/3rd/mp/test.c
@@ -333,6 +333,9 @@
b3 = mpnew(0);
mpsub(b1, b2, b3);
printf("%s - %s = %s\n", MP(b1), MP(b2), MP(b3));
+ mpfree(b1);
+ mpfree(b2);
+ mpfree(b3);
}
static void
@@ -345,6 +348,9 @@
b3 = mpnew(0);
mpmul(b1, b2, b3);
printf("%s * %s = %s\n", MP(b1), MP(b2), MP(b3));
+ mpfree(b1);
+ mpfree(b2);
+ mpfree(b3);
}
static void
@@ -479,12 +485,18 @@
x = mprand(256, prng, nil);
y = mprand(128, prng, nil);
testdiv(x, y);
+ mpfree(x);
+ mpfree(y);
x = mprand(2048, prng, nil);
y = mprand(1024, prng, nil);
testdiv(x, y);
+ mpfree(x);
+ mpfree(y);
x = mprand(4*1024, prng, nil);
y = mprand(4*1024, prng, nil);
testmul2(x, y);
+ mpfree(x);
+ mpfree(y);
testsub1("677132C9", "-A26559B6");
testgcd();
x = mprand(512, prng, nil);
@@ -494,6 +506,8 @@
testmod(x, y);
x->sign = 1;
testinvert(y, x);
+ mpfree(x);
+ mpfree(y);
testexp("111111111", "222", "1000000000000000000000");
testexp("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", "100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000");
return 0;