_mp_alloc vs ALLOC
bodrato at mail.dm.unipi.it
bodrato at mail.dm.unipi.it
Thu May 31 13:49:42 CEST 2012
Ciao,
I'm looking inside the mpq directory, to perform something similar to
Torbjorn's change "mpz: Use MPZ_REALLOC return value when possible",
that's why I revive an old question...
Il Ven, 24 Febbraio 2012 12:32 pm, Torbjorn Granlund ha scritto:
> bodrato at mail.dm.unipi.it writes:
> I always used the MPZ_REALLOC macro, to enlarge (if needed) the memory
> area available for an integer. This macro gives a (possibly new) pointer
> with the requested size available... but it also copies the content.
>
> Sometimes I know in advance that the content can be discarded. Is there
> I use this trick for that:
>
> rp = realloc (rp, 1);
> rp = realloc (rp, newsize);
>
> I suspect there is a lot to win from using such a trick, at least of the
...
> I am not sure how to deal with this in GMP. We could add a flag field
> in MPZ_REALLOC, or have special functions+macros.
Most of the uses of MPZ_REALLOC in mpq don't need the data relocation at
all, because the next step usually consists in overwriting them.
Do you mind if I define a new macro MPZ_NEWALLOC?
Currently it should be the same as MPZ_REALLOC, but it can be changed in
the future...
Regards,
Marco
PS: I'm also removing LIMBS from gmp-impl.h, an alias for PTR.
--
http://bodrato.it/papers/
More information about the gmp-devel
mailing list