Add a Statement class to manage the sqlite3_stmt objects and avoid leaks
This commit is contained in:
@@ -19,14 +19,14 @@ struct CountQuery: public Query
|
||||
{
|
||||
auto statement = this->prepare(db);
|
||||
std::size_t res = 0;
|
||||
if (sqlite3_step(statement) == SQLITE_ROW)
|
||||
res = sqlite3_column_int64(statement, 0);
|
||||
if (sqlite3_step(statement.get()) == SQLITE_ROW)
|
||||
res = sqlite3_column_int64(statement.get(), 0);
|
||||
else
|
||||
{
|
||||
log_error("Count request didn’t return a result");
|
||||
return 0;
|
||||
}
|
||||
if (sqlite3_step(statement) != SQLITE_DONE)
|
||||
if (sqlite3_step(statement.get()) != SQLITE_DONE)
|
||||
log_warning("Count request returned more than one result.");
|
||||
|
||||
log_debug("Returning count: ", res);
|
||||
|
||||
Reference in New Issue
Block a user