_mp_alloc vs ALLOC

Torbjorn Granlund tg at gmplib.org
Wed Feb 22 19:41:17 CET 2012


Marc Glisse <marc.glisse at inria.fr> writes:

  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?
  
You're welcome to clean up this.  The macro LIMBS is used in just one
file, AFAICT, I have  no idea why it exists

  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.
  
That'd be fine too.

-- 
Torbjörn


More information about the gmp-devel mailing list