Is this redundant?

Paul Zimmermann Paul.Zimmermann at loria.fr
Sun Nov 16 20:54:03 CET 2008


>    if (UNLIKELY (res->_mp_alloc < res_size))
>      {
>        _mpz_realloc (res, res_size);
>        op1_ptr = op1->_mp_d;
>        op2_ptr = op2->_mp_d;
>       //** nobody modified op1_ptr,op1->_mp_d,op2_ptr,op2->_mp_d. Why do we
> need to this again?
>        res_ptr = res->_mp_d;
>      }
> I think it is redundant.

Remember that res might equal op1 and/or op2. In that case the call
to _mpz_realloc will change the pointer op1->_mp_d and/or op2->_mp_d.

However if res = op1 or res = op1, then I guess
ALLOC(res) >= min(ALLOC(op1), ALLOC(op2)) is true, thus it seems to me that
the case ALLOC(res) < res_size <= MIN (op1_size, op2_size) cannot happen.
At least this case is not covered by "make check".

Paul Zimmermann


More information about the gmp-discuss mailing list