PDA

View Full Version : Value stored to 'dwDelay' is never read




rbeatajane
Jun 16, 2011, 01:13 AM
Hi


The function below is causing me memory leak. I dont know why.
I'm using dwDelay but its telling me dwDelay is never read.What mistake am i doing here.

-(uint8_t)timeoutThread
{
unsigned long int dwDelay = 0;
some stmts;
while()
{
stmts;
}
dwDelay = 1000; //memory leak(value stored to 'dwDelay' is never read)
}



robbieduncan
Jun 16, 2011, 04:48 AM
I don't see how that will leak memory: dwDelay is a stack variable. It's not storing a pointer to something on the heap so at the end of the method it's storage will automatically be recovered from the stack. The analyser is correct though: that last statement has no point as the value can never be read.