summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Eitzenberger <heitzenberger@astaro.com>2009-10-09 13:29:07 +0200
committerHarald Welte <laforge@gnumonks.org>2010-10-21 19:15:37 +0200
commit9f15b2b3fa2805f504cc49c58075de3f9997fee5 (patch)
tree3d8572e4d459407d1fa14a00ae22ace0565e46c3
parent4e2f01801fdd020e35c198813c2efd77aab81c8d (diff)
db: use ulogd_free_keyset() instead of open-coded version
Signed-off-by: Holger Eitzenberger <heitzenberger@astaro.com>
-rw-r--r--output/mysql/ulogd_output_MYSQL.c4
-rw-r--r--output/pgsql/ulogd_output_PGSQL.c3
-rw-r--r--src/db.c9
-rw-r--r--src/plugin.c5
4 files changed, 5 insertions, 16 deletions
diff --git a/output/mysql/ulogd_output_MYSQL.c b/output/mysql/ulogd_output_MYSQL.c
index 769077d..fb2ff74 100644
--- a/output/mysql/ulogd_output_MYSQL.c
+++ b/output/mysql/ulogd_output_MYSQL.c
@@ -123,10 +123,6 @@ static int get_columns_mysql(struct ulogd_pluginstance *upi)
* in case the core just calls ->configure() and then aborts (and thus
* never free()s the memory we allocate here. FIXME. */
- /* Cleanup before reconnect */
- if (upi->input.keys)
- free(upi->input.keys);
-
upi->input.num_keys = mysql_num_fields(result);
ulogd_log(ULOGD_DEBUG, "%u fields in table\n", upi->input.num_keys);
upi->input.keys = malloc(sizeof(struct ulogd_key) *
diff --git a/output/pgsql/ulogd_output_PGSQL.c b/output/pgsql/ulogd_output_PGSQL.c
index 3b9fd22..679315b 100644
--- a/output/pgsql/ulogd_output_PGSQL.c
+++ b/output/pgsql/ulogd_output_PGSQL.c
@@ -203,9 +203,6 @@ pgsql_get_columns(struct ulogd_pluginstance *upi)
goto err_again;
}
- if (upi->input.keys != NULL)
- free(upi->input.keys);
-
tuples = upi->input.num_keys = PQntuples(priv->pgres);
/* ignore columns with leading underscore */
diff --git a/src/db.c b/src/db.c
index bde3936..8cdbb53 100644
--- a/src/db.c
+++ b/src/db.c
@@ -641,14 +641,7 @@ ulogd_db_stop(struct ulogd_pluginstance *upi)
db_close(upi);
upi_log(upi, ULOGD_INFO, "database connection closed\n");
- /* try to free our dynamically allocated input key array */
- if (upi->input.keys) {
- upi->input.num_keys = 0;
-
- free(upi->input.keys);
- upi->input.keys = NULL;
- }
-
+ ulogd_free_keyset(&upi->input);
ulogd_unregister_timer(&di->timer);
return 0;
diff --git a/src/plugin.c b/src/plugin.c
index e46711e..aecc12f 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -1323,9 +1323,12 @@ ulogd_free_keyset(struct ulogd_keyset *set)
{
int i;
+ if (!set || !set->num_keys)
+ return;
+
if (set->flags & KEYSET_F_ALLOC) {
for (i = 0; i < set->num_keys; i++)
- free(&set->keys[i]);
+ free(set->keys[i].name);
}
free(set->keys);