I have several routines which are used millions of times in my
programs, using the Gnu multi-precision software's floating-point reals
(see <http://www.swox.se/gmp>). These are of type mpf_t, and I must
explicitly initialize (and later free) all temporary variables of this
type.
So I hit on the idea of something like this:
static int firstcall = 1;
mpf_t temp;
if (firstcall) {
firstcall = 0;
mpf_init(temp);
}
else blahblah
First time through, firstcall is 1, so temp gets initialized. Second
(and later) times through, temp is already initialized (with what
values I don't care, because i'll reset them) and doesn't get
REinitialized (which would be a fatal error).
It passes -Wall, and it seems to work. Is it legal? Is there anything
I need to look out for?
Initializing, and then freeing, an mpf_t millions of times is not
something I want to do. Especially since it may be thousands of bytes
long.
I should add, I don't care that I never free temp. The program exits
before this would become a problem.
--Ron Bruck
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com