projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
postgresql plugin: constify
[collectd.git]
/
src
/
postgresql.c
diff --git
a/src/postgresql.c
b/src/postgresql.c
index
e68fd32
..
7922683
100644
(file)
--- a/
src/postgresql.c
+++ b/
src/postgresql.c
@@
-154,7
+154,7
@@
typedef struct {
int ref_cnt;
} c_psql_database_t;
int ref_cnt;
} c_psql_database_t;
-static c
har *
def_queries[] = {
+static c
onst char *const
def_queries[] = {
"backends",
"transactions",
"queries",
"backends",
"transactions",
"queries",
@@
-429,9
+429,9
@@
static PGresult *c_psql_exec_query_noparams (c_psql_database_t *db,
static PGresult *c_psql_exec_query_params (c_psql_database_t *db,
udb_query_t *q, c_psql_user_data_t *data)
{
static PGresult *c_psql_exec_query_params (c_psql_database_t *db,
udb_query_t *q, c_psql_user_data_t *data)
{
- char *params[db->max_params_num];
- char interval[64];
- int i;
+ c
onst c
har *params[db->max_params_num];
+ char
interval[64];
+ int
i;
if ((data == NULL) || (data->params_num == 0))
return (c_psql_exec_query_noparams (db, q));
if ((data == NULL) || (data->params_num == 0))
return (c_psql_exec_query_noparams (db, q));
@@
-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 = udb_query_get_user_data (q);
if (NULL == data) {
- data =
(c_psql_user_data_t *) s
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;
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;
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++;
}
data->params_num++;
- udb_query_set_user_data (q, data);
-
return (0);
} /* config_query_param_add */
return (0);
} /* config_query_param_add */
@@
-1161,7
+1161,7
@@
static int c_psql_config_writer (oconfig_item_t *ci)
writers = tmp;
writer = writers + writers_num;
writers = tmp;
writer = writers + writers_num;
-
++writers_num
;
+
memset (writer, 0, sizeof (*writer))
;
writer->name = sstrdup (ci->values[0].value.string);
writer->statement = NULL;
writer->name = sstrdup (ci->values[0].value.string);
writer->statement = NULL;
@@
-1181,10
+1181,10
@@
static int c_psql_config_writer (oconfig_item_t *ci)
if (status != 0) {
sfree (writer->statement);
sfree (writer->name);
if (status != 0) {
sfree (writer->statement);
sfree (writer->name);
- sfree (writer);
return status;
}
return status;
}
+ ++writers_num;
return 0;
} /* c_psql_config_writer */
return 0;
} /* c_psql_config_writer */