[Icc-avr] Freeing static variables

Michael Dipperstein MDipperstein at CalAmp.com
Mon Oct 22 13:21:59 PDT 2007


Can you reuse the space instead of releasing it?  If you have the need for two static variables that can share the same memory location, you can just use it for two purposes.  You can use #defines if you'd like it to look like you're using two different variables.

 

#define calibrationVar     staticVar

#define otherVar             staticVar

static int staticVar;

 

-----Original Message-----
From: icc-avr-bounces at imagecraft.com [mailto:icc-avr-bounces at imagecraft.com] On Behalf Of Bengt Ragnemalm
Sent: Monday, October 22, 2007 1:17 AM
To: ICC-AVR discussion list
Subject: [Icc-avr] Freeing static variables

 

Is there any intelligent way to release the memory used by a static variable?

 

I have a calibration routine that is run the first loops of the program. If the calibration was done in a separate function , I could just use temporary variables but as this is run in the entire normal program loop I can not see any other way than to use statics for my temporary variables in the calibration routine.

 

But after the calibrating is done, it would have been nice to free the space used by the static variables.

 

Maybe there is some better way to do this so any suggestions are welcome.

 

Regards,

Bengt

________________________________________________________________

Bengt Ragnemalm                        Tel +46 13 22 24 97

Research engineer                                       FAX: +46 13 10 19 02

Linköpings Universitet                                mailto:bengt.ragnemalm at imt.liu.se <mailto:bengt.ragnemalm at imt.liu.se> 

Inst. för Medicinsk Teknik Internet:        http://www.imt.liu.se <http://www.imt.liu.se/> 

S-581 85 Linköping SWEDEN

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://dragonsgate.net/pipermail/icc-avr/attachments/20071022/beb86227/attachment.html


More information about the Icc-avr mailing list