_mp_alloc vs ALLOC

Marc Glisse marc.glisse at inria.fr
Wed Feb 22 19:18:58 CET 2012


Hello,

is there any objection if I replace most uses of ->_mp_alloc by calls to 
the ALLOC macro in mp[zqf] (and similarly for _mp_size, etc)? It helps 
when experimenting... I am also considering moving the NUM and DEN macros 
from test/mpq/t-cmp* to gmp-impl.h, since I assume mpq_numref and 
mpq_denref are not used much internally because of their length. By the 
way, is there any difference between PTR and LIMBS? Say one that should be 
used in some circumstances and one in others?

Unrelated, I was thinking of changing (when gmp is compiled with a C++ 
compiler, so that wouldn't affect many people...) the definitions of 
TMP_DECL and TMP_FREE so TMP_DECL would create a variable whose destructor 
(executed when the variable goes out of scope, which shouldn't be far from 
where TMP_FREE is currently called) does what TMP_FREE currently does. The 
advantage is that in case an exception is thrown in between, the 
destructor is executed. That doesn't solve all memory issues by far, but 
it is a first step that costs little in terms of code and 0 in speed.

I am not saying I will do either any time soon, just checking first.

-- 
Marc Glisse


More information about the gmp-devel mailing list