summaryrefslogtreecommitdiff
path: root/src/analysis/db/collection.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/analysis/db/collection.c')
-rw-r--r--src/analysis/db/collection.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/src/analysis/db/collection.c b/src/analysis/db/collection.c
index aa7591e..09d9c90 100644
--- a/src/analysis/db/collection.c
+++ b/src/analysis/db/collection.c
@@ -949,11 +949,11 @@ bool g_db_collection_load_all_items(GDbCollection *collec, sqlite3 *db)
int native_type; /* Type de valeur dans la base */
GDbItem *new; /* Nouvel élément à insérer */
- if (!g_db_collection_setup_load(collec, &values, &count))
- return false;
-
result = false;
+ if (!g_db_collection_setup_load(collec, &values, &count))
+ goto gdclai_building_values;
+
/* Préparation de la requête */
sql = strdup("SELECT ");
@@ -1074,6 +1074,10 @@ bool g_db_collection_load_all_items(GDbCollection *collec, sqlite3 *db)
free(sql);
+ gdclai_building_values:
+
+ free_all_bound_values(values, count);
+
return result;
}
@@ -1104,11 +1108,11 @@ static bool g_db_collection_store_item(const GDbCollection *collec, const GDbIte
int ret; /* Bilan d'un appel à SQLite */
int index; /* Indice de valeur attachée */
- if (!g_db_item_prepare_db_statement(item, &values, &count))
- return false;
-
result = false;
+ if (!g_db_item_prepare_db_statement(item, &values, &count))
+ goto gdcsi_building_values;
+
/* Préparation de la requête */
sql = strdup("INSERT INTO ");
@@ -1212,6 +1216,10 @@ static bool g_db_collection_store_item(const GDbCollection *collec, const GDbIte
free(sql);
+ gdcsi_building_values:
+
+ free_all_bound_values(values, count);
+
return result;
}
@@ -1244,11 +1252,11 @@ static bool g_db_collection_store_updated_item(const GDbCollection *collec, cons
int index; /* Indice de valeur attachée */
const bound_value *timestamp; /* Valeur de l'horodatage */
- if (!g_db_item_prepare_db_statement(item, &values, &count))
- return false;
-
result = false;
+ if (!g_db_item_prepare_db_statement(item, &values, &count))
+ goto gdcsui_building_values;
+
/* Préparation de la requête */
sql = strdup("UPDATE ");
@@ -1290,7 +1298,7 @@ static bool g_db_collection_store_updated_item(const GDbCollection *collec, cons
if (ret != SQLITE_OK)
{
fprintf(stderr, "Can't prepare UPDATE statment '%s' (ret=%d): %s\n", sql, ret, sqlite3_errmsg(db));
- goto gdcsi_exit;
+ goto gdcsui_exit;
}
/* Attribution des valeurs */
@@ -1307,7 +1315,7 @@ static bool g_db_collection_store_updated_item(const GDbCollection *collec, cons
{
fprintf(stderr, "Can't bind value for parameter nb %d in '%s' (ret=%d): %s\n",
index - 1, sql, ret, sqlite3_errmsg(db));
- goto gdcsi_exit;
+ goto gdcsui_exit;
}
for (i = 0; i < count; i++)
@@ -1353,7 +1361,7 @@ static bool g_db_collection_store_updated_item(const GDbCollection *collec, cons
{
fprintf(stderr, "Can't bind value for parameter nb %d in '%s' (ret=%d): %s\n",
index - 1, sql, ret, sqlite3_errmsg(db));
- goto gdcsi_exit;
+ goto gdcsui_exit;
}
}
@@ -1365,17 +1373,21 @@ static bool g_db_collection_store_updated_item(const GDbCollection *collec, cons
if (ret != SQLITE_DONE)
{
fprintf(stderr, "UPDATE statement '%s' didn't return DONE (ret=%d): %s\n", sql, ret, sqlite3_errmsg(db));
- goto gdcsi_exit;
+ goto gdcsui_exit;
}
sqlite3_finalize(stmt);
result = true;
- gdcsi_exit:
+ gdcsui_exit:
free(sql);
+ gdcsui_building_values:
+
+ free_all_bound_values(values, count);
+
return result;
}