I'm using GMP and I need an array of mpz_t
. sizeof(mpz_t)
gives 16, but the numbers I'm storing are considerably larger than that. Does mpz_t
grow "in place", i. e. do I need to allocate more memory and allow for growth in-place, or does GMP allocate the space for them elsewhere and just keep references (in which case, I'm assuming, I won't have to take any special precautions.)
It is safe to declare an array to store a number of mpz_t
values. According to the GNU MP manual:
mpz_t
is actually implemented as a one-element array of a certain structure type. This is why using it to declare a variable gives an object with the fields GMP needs, but then using it as a parameter passes a pointer to the object. Note that the actual contents of anmpz_t
are for internal use only and you should not access them directly if you want your code to be compatible with future GMP releases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With