I just put a return instruction in a middle of an while/if test. Does it leak memory? By the way, sorry about Finnish names in the variables. I am reinventing the GSM wheel and I don't like at like at all.
int read_sms()
{
int varao, varak, varaln, varaf, loppu;
char merkki[2];
int laskuri;
strcpy(viesti,'\0');
strcpy(merkki,'\0');
Serial1.print("AT+CMGRD=0");
Serial1.print('\r');
Serial1.print('\n');
loppu=0;
varao=0;
varak=0;
varaln=0;
laskuri=0;
while (loppu!=1)
{
while(Serial1.available() > 0 )
{
varaf = Serial1.read();
laskuri++;
varao=varak;
varak=varaln;
varaln=varaf;
varaf=sprintf (merkki,"%c",varaf);
if (varaln=='\r' && varao=='O' && varak=='K')
{
loppu=1;
}
//error, no more messages
if (laskuri==22 && varao=='E' && varak=='R')
{
loppu=1;
Serial.println("error no more msg");
//is this bad
return 0;
}
}
}
strcat(viesti, '\0');
return laskuri;
}
I can see bugs and design errors in you're code but they are yours and NOT C/C++ or IDE bugs. Try laying out your code (which is some thing you should do before posting in any case).
holmes4:
I can see bugs and design errors in you're code but they are yours and NOT C/C++ or IDE bugs. Try laying out your code (which is some thing you should do before posting in any case).
Mark
Memory leaks may or may not happen, no matter what I'll do elsewhere. There sure are bugs