GMP memory leakage global variable

chmol10@wp.pl chmol10 at wp.pl
Sun Jul 4 22:41:13 UTC 2021


Hi,     I have a problem with variable l. The during the do-while loop execution, variable l is still in use and memory is leaking. The loop is endlessly executing. How to repair this leakage? Here is the main part of the code:   mpz_t l;

    int main
    {
        mpz_init(n);
        mpz_init(l);

gmp_scanf("%Zd", (value);
mpz_t (rand);
mpz_init(rand);
unsign long seed;
gmp_randstate_t rstate;
gmp_randinit_mt(rstate seed);

mpz_init_set_si(value, 100000000000000000);


        do
        {
        
               mpz_clear(n);
               mpz_init (n);
               mpz_set(n, l);
               analyze(n);
               mpz_urandomm(rand, rstate, value);
               mpz_add_ui(rand,rand,1);
               mpz_add(l,l,rand);
        
        }while(1);
    }  Thank you for you help.   Best wishes   Paweł Chmolewski


More information about the gmp-discuss mailing list