Re: [mpir-devel] How To Distinguish Initialized from Cleared Var?

2011-04-30 Thread Bob Smith
On 4/30/2011 8:04 PM, Bill Hart wrote: The internals of the struct don't change when calling mpz_clear. The only thing you could do is wrap mpz_clear in a function which modifies one of the fields and call that instead, e.g. set _mp_alloc to 0 and _mp_size to 1. However it is undocumented that mp

Re: [mpir-devel] How To Distinguish Initialized from Cleared Var?

2011-04-30 Thread Bill Hart
The internals of the struct don't change when calling mpz_clear. The only thing you could do is wrap mpz_clear in a function which modifies one of the fields and call that instead, e.g. set _mp_alloc to 0 and _mp_size to 1. However it is undocumented that mpz_init sets _mp_alloc to 1 and _mp_size t

[mpir-devel] How To Distinguish Initialized from Cleared Var?

2011-04-30 Thread Sudleyplace
To avoid memory leaks, at the end of routines that use mpz/mpq/mpf vars I want to free the ones that have been initialized, but not the ones that haven't. I would greatly prefer to do this at the end rather than track each var's status throughout the code. In C, I declare a var as (say) MP_INT m