Any idea why this function is leaking memory every time I call it?
char *getData(sqlite3 *db)
{
char *ret;
sqlite3_stmt *res;
int rc = sqlite3_prepare_v2(db, SELECT_STATEMENT_SQL, -1, &res, 0);
if (rc != SQLITE_OK) {
sprintf(stderr, "%s\n", sqlite3_errmsg(db));
return stderr;
}
rc = sqlite3_step(res);
if (rc == SQLITE_ROW) {
ret = sqlite3_column_text(res, 0);
} else {
ret = "error!";
}
sqlite3_free(res);
return ret;
}
Aucun commentaire:
Enregistrer un commentaire