Patch to allow more granular aborting.

Theo Schlossnagle jesus at omniti.com
Mon Mar 14 20:20:35 CET 2011


On Mon, Mar 14, 2011 at 5:02 AM, Niels Möller <nisse at lysator.liu.se> wrote:
> 1. About out-of-memory.
>
> Can you explain why the current interface doesn't suffice? You can
> provide your own allocation function, and make them raise an error in
> any way you please on failure, instead of returning NULL to the caller.

It does look like I can replace the realloc calls:

gmp-impl.h defines:

1753 #define MPZ_REALLOC(z,n) (UNLIKELY ((n) > ALLOC(z))     \
1754                           ? (mp_ptr) _mpz_realloc(z,n)  \
1755                           : PTR(z))

which bypasses any replacement of __gmp_reallocate_func.

So, for example, in mpz/n_pow_ui, when it calls MPZ_REALLOC, I'm stuck
with the abort()

In fact, it appears that very few places in the code leverage
__gmp_reallocate_func


-- 
Theo Schlossnagle

http://omniti.com/is/theo-schlossnagle


More information about the gmp-devel mailing list