_mp_alloc vs ALLOC

Niels Möller nisse at lysator.liu.se
Fri Feb 24 12:26:20 CET 2012

bodrato at mail.dm.unipi.it writes:

> Inspired from mpz/mul.c... Maybe we can write a macro based on:
> (*__gmp_free_func) (PTR(x), ALLOC (x) * BYTES_PER_MP_LIMB);
> ALLOC (x) = newsize;
> PTR(x) = (mp_ptr) (*__gmp_allocate_func) (newsize * BYTES_PER_MP_LIMB);

That's going to be more expensive in the case that the allocator could
grow the block in place. I imagine that's a likely case when the new
size is just slightly larger than the old size.


Niels Möller. PGP-encrypted email is preferred. Keyid C0B98E26.
Internet email is subject to wholesale government surveillance.

More information about the gmp-devel mailing list