while (1)
{
/* scrolling the result set rows */
ret = sqlite3_step (stmt);
if (ret == SQLITE_DONE)
break; /* end of result set */
if (ret == SQLITE_ROW)
{
const char *v = (const char *) sqlite3_column_text (stmt, 0);
int len = sqlite3_column_bytes (stmt, 0);
if (rt)
free (rt);
rt = malloc (len + 1);
strcpy (rt, v);
v = (const char *) sqlite3_column_text (stmt, 1);
len = sqlite3_column_bytes (stmt, 1);
if (rg)
free (rg);
rg = malloc (len + 1);
strcpy (rg, v);
count++;
}
else
{
// ------------bug fix ----------------
if (rg != NULL)
free (rg);
if (rt != NULL)
free (rt);
sqlite3_finalize (stmt);
return 0;
}
}