Questions.. Questions ..
Torbjorn Granlund
tege at swox.com
Mon Nov 28 22:57:37 CET 2005
Lucien Hayen <l.hayen at tiscali.be> writes:
1) I have version 4.1.4 but the macros __GMPF_BITS_TO_PREC and
__GMPF_PREC_TO_BITS do not seem to exist.
These are internals.
2) The expression sizeof(mp_limb_t) popped up so many times that
inclusion of the exact numerical value (4 on my system) in gmp.h
(as it is generated for each particular system) seems to be
reasonable : #define GMP_LIMB_BYTES 4 (or whatever is the case).
It is there.
3) The mpz_t structure element _mp_prec seems to have two
different and contradictory uses : at init time the number of
limbs to use as precision, and the number of limbs allocated (-1).
Later on this last meaning may be lost.
Would it not be better to insert a _mp_alloc (or more clearly)
a _mp_prec_max item in the mpf_t structure ? No more problems
at clear time, no more mpf_set_prec_raw() accidents if the maximum
precision is silently or otherwise enforced (warning on page 47 of
the manual).
Keeping the structure small was an important design goal.
4) Clearing in general does deallocate memory, but keeps a pointer
to now non existing memory, or worse yet, to memory allocated
after the clear operation for purposes that need not even be
related to GMP uses. Why not setting _mp_d to NULL so that any
accidental second clear operation will fail there and then. Now
it can happen somewhere later, deeper in the software, and
possibly difficult to find.
Could be done, I suppose. I don't think it would solve much of
the inherent danger with C.
--
Torbjörn
More information about the gmp-discuss
mailing list