_ptr and _srcptr types
nisse at lysator.liu.se
Wed May 16 12:04:02 UTC 2018
tg at gmplib.org (Torbjörn Granlund) writes:
> I also think usage of mpz_roinit_n might lead to memory leaks, triggered
> by mpz_init (or lack of mpz_clear) before its use. We need to point
> this out.
The name suggests that it part of the mpz_init family of functions,
which should only be used on uninitialized mpz objects. But this could be
made more explicit, and we should also mention that mpz_ronit_n
shouldn't be followed by mpz_clear.
> I believe that both types will not change their role or definition in the
> near future, as such they can be documented.
> I'm not sure about: how we should explain how to use them.
> That is a challenge.
It shouldn't be so difficult for users familiar with the fine points of
arrays and pointers in C. mpz_t is a typedef for a size 1 array
containing the internal struct, and mpz_ptr is a pointer to the same
struct, i.e., the type that an mpz_t "decays" to in expression context.
> (Should we provide similar types for mpq and mpf?)
Yes. In m opinion, every advertised typedef of an array type should have
a corresponding advertised pointer type.
Niels Möller. PGP-encrypted email is preferred. Keyid 368C6677.
Internet email is subject to wholesale government surveillance.
More information about the gmp-devel