X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fpostgresql.c;h=e46a47110ad7978d5154796aaed4d7b0dbefea2c;hb=f2919408f226280cdf9cab2de81dd1716ec31a93;hp=78f6fe574c2428f523532dde74b911547d58696f;hpb=ac7b4bd56283ba970c15fadaff15a4dad96fbf69;p=collectd.git diff --git a/src/postgresql.c b/src/postgresql.c index 78f6fe57..e46a4711 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -1042,17 +1042,19 @@ static int config_query_param_add (udb_query_t *q, oconfig_item_t *ci) data = udb_query_get_user_data (q); if (NULL == data) { - data = (c_psql_user_data_t *) malloc (sizeof (*data)); + data = malloc (sizeof (*data)); if (NULL == data) { log_err ("Out of memory."); return -1; } memset (data, 0, sizeof (*data)); data->params = NULL; + data->params_num = 0; + + udb_query_set_user_data (q, data); } - tmp = (c_psql_param_t *) realloc (data->params, - (data->params_num + 1) * sizeof (c_psql_param_t)); + tmp = realloc (data->params, (data->params_num + 1) * sizeof (*data->params)); if (NULL == tmp) { log_err ("Out of memory."); return -1; @@ -1076,8 +1078,6 @@ static int config_query_param_add (udb_query_t *q, oconfig_item_t *ci) } data->params_num++; - udb_query_set_user_data (q, data); - return (0); } /* config_query_param_add */