Multiple statements in the same query does not leak memory anymore.

[GB.DB.SQLITE3]
* BUG: Multiple statements in the same query does not leak memory anymore. In that case, the result of the last statement is returned.
This commit is contained in:
gambas 2019-05-14 01:25:51 +02:00
parent 11787a122e
commit c1bc03ccfa

View file

@ -244,6 +244,33 @@ GB_TYPE sqlite_get_type(const char *type, int *length)
//--------------------------------------------------------------------------
static void clear_query(SQLITE_RESULT *result)
{
int i;
if (!result->buffer)
return;
for (i = 0; i < result->ncol; i++)
GB.FreeString(&result->names[i]);
GB.Free(POINTER(&result->names));
GB.Free(POINTER(&result->types));
GB.Free(POINTER(&result->lengths));
GB.FreeArray(&result->values);
BUFFER_delete(&result->buffer);
}
void sqlite_query_free(SQLITE_RESULT *result)
{
clear_query(result);
GB.Free(POINTER(&result));
}
static int my_sqlite3_exec(
sqlite3 *db, /* The database on which the SQL executes */
const char *zSql, /* The SQL to be executed */
@ -283,6 +310,10 @@ static int my_sqlite3_exec(
nCallback = 0;
clear_query(result);
BUFFER_create(&result->buffer);
result->ncol = ncol = sqlite3_column_count(pStmt);
if (ncol > 0)
@ -409,7 +440,6 @@ SQLITE_RESULT *sqlite_query_exec(SQLITE_DATABASE *db, const char *query, bool ne
int res;
GB.AllocZero(POINTER(&result), sizeof(SQLITE_RESULT));
BUFFER_create(&result->buffer);
for (retry = 1; retry <= 2; retry++)
{
@ -428,26 +458,6 @@ SQLITE_RESULT *sqlite_query_exec(SQLITE_DATABASE *db, const char *query, bool ne
return result;
}
void sqlite_query_free(SQLITE_RESULT *result)
{
int i;
for (i = 0; i < result->ncol; i++)
GB.FreeString(&result->names[i]);
GB.Free(POINTER(&result->names));
GB.Free(POINTER(&result->types));
GB.Free(POINTER(&result->lengths));
GB.FreeArray(&result->values);
BUFFER_delete(&result->buffer);
GB.Free(POINTER(&result));
}
void sqlite_query_get(SQLITE_RESULT *result, int pos, int col, char **value, int *length)
{
int i;