I have a funcA which I call every msec. by another funcB. I want to use goto statement. But when I look at the flow (when m_tempdata is not NULL), after printing "stage 2", it is also printing "cleanup starts". Normally, I expect to return after printing "stage 2" for the next turn. Am I wrong?
void ClassA::funcA()
{
m_tempdata = m_freedata;
printf("stage 1 \n");
if (NULL == m_tempdata)
{
printf("going cleaning \n" );
goto cleanup;
}
m_freedata = m_tempdata->next;
printf("stage 2 \n");
cleanup: printf("cleanup starts \n");
// ... some additional work todo
}
cleanup:is just a label between your statements. Also, there's no good reason to justifygotohere :v