On Nov 8, 5:44 pm, Bob Smith <bsm...@sudleyplace.com> wrote:
> On 11/4/2011 8:01 PM, Marc wrote:
>
> > On Nov 5, 12:23 am, Bob Smith<bsm...@sudleyplace.com>  wrote:
> >> Using MPIR 2.4.0, I'm substituting my own memory allocator which gets
> >> called from tal-reent.c in __gmp_tmp_reentrant_alloc.  The code in that
> >> function doesn't check to see if the allocation failed and immediately
> >> writes into the memory, allocated or not.
>
> >> How should I indicate that the allocation failed so your code and my
> >> code may recover cleanly?
>
> > You can't, but the closest you can get is to throw an exception (note
> > that with gcc it may require compiling mpir with -fexceptions).
>
> How does throwing an exception (to be caught in my code that calls some
> MPIR function) allow the MPIR code to clean up after itself?  Isn't this
> likely to create a memory leak?

It is, hence my answer: "You can't, but the closest you can get
[...]". Note that changing TMP_DECL to declaring an object whose
destructor does what TMP_FREE currently does would solve most of this.
And as long as only alloca is used, there is no leak.

-- 
You received this message because you are subscribed to the Google Groups 
"mpir-devel" group.
To post to this group, send email to mpir-devel@googlegroups.com.
To unsubscribe from this group, send email to 
mpir-devel+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/mpir-devel?hl=en.

Reply via email to