mpz_gcd_ext(NULL, ...)

Niels Möller nisse at lysator.liu.se
Wed Jan 18 18:02:56 UTC 2017


"Marco Bodrato" <bodrato at mail.dm.unipi.it> writes:

>Il Dom, 1 Gennaio 2017 7:30 pm, Niels Möller ha scritto:
>> You did one more thing in the committed change 84ce52f0d360:
>
>> @@ -64,7 +64,7 @@ mpz_gcdext (mpz_ptr g, mpz_ptr s, mpz_pt
>>
>>        if (g != NULL)
>>  	{
>> -	  gp = MPZ_REALLOC (g, asize);
>> +	  gp = MPZ_NEWALLOC (g, asize);
>>  	  MPN_COPY (gp, PTR (a), asize);
>>  	  SIZ (g) = asize;
>>  	}
>
>> That will break in case g == a, right?
>
> No, it will not. If g == a, ALLOC (g) is not smaller than asize, so that
> MPZ_*ALLOC will leave it untouched.

Ah, I see. That's subtle (and perhaps comment-worthy...).

Regards,
/Niels

-- 
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.


More information about the gmp-devel mailing list