How to use GMP.
Thu, 08 May 2003 07:43:45 +1000
Hashida <firstname.lastname@example.org> writes:
> MP_INT *bbbbb=(MP_INT *)malloc(50);
You should use sizeof(MP_INT) if you really want to do it with malloc.
> bbbbb->_mp_d=(mp_limb_t *)malloc(10);
No, gmp manages the space at _mp_d, mpz_init and friends will set it.
This is correct, but you need to look at _mp_d too, since the value
is two limbs of 32 bits. This is all internals though, so if you want
to be compatible with future releases, don't do it.
> Is "MP_INT" equal to "mpz_t" ?
No, with MP_INT you get a struct, with mpz_t you get a one element
array. The difference is that for MP_INT you need to write "&x" like
you did with "&aaaaa" to get a pointer to pass. With mpz_t that