X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fpostgresql.c;h=3b125ee8bd5149a2d7b7c9720c4dd8501ce5030a;hb=4103105fb43cd72294f165b2541540b3a8a99532;hp=b4b4ca7769d2933bb137821a014b36ebcac98951;hpb=2df75b141dc7474a72ce949bd0ce1ca5739e6fef;p=collectd.git diff --git a/src/postgresql.c b/src/postgresql.c index b4b4ca77..3b125ee8 100644 --- a/src/postgresql.c +++ b/src/postgresql.c @@ -31,6 +31,7 @@ */ #include "collectd.h" + #include "common.h" #include "configfile.h" @@ -40,10 +41,6 @@ #include "utils_db_query.h" #include "utils_complain.h" -#if HAVE_PTHREAD_H -# include -#endif - #include #include @@ -224,7 +221,7 @@ static c_psql_database_t *c_psql_database_new (const char *name) return NULL; } - tmp = (c_psql_database_t **)realloc (databases, + tmp = realloc (databases, (databases_num + 1) * sizeof (*databases)); if (NULL == tmp) { log_err ("Out of memory."); @@ -1115,7 +1112,7 @@ static int config_add_writer (oconfig_item_t *ci, if (strcasecmp (name, src_writers[i].name) != 0) continue; - tmp = (c_psql_writer_t **)realloc (*dst_writers, + tmp = realloc (*dst_writers, sizeof (**dst_writers) * (*dst_writers_num + 1)); if (tmp == NULL) { log_err ("Out of memory."); @@ -1151,7 +1148,7 @@ static int c_psql_config_writer (oconfig_item_t *ci) return 1; } - tmp = (c_psql_writer_t *)realloc (writers, + tmp = realloc (writers, sizeof (*writers) * (writers_num + 1)); if (tmp == NULL) { log_err ("Out of memory."); @@ -1192,7 +1189,7 @@ static int c_psql_config_database (oconfig_item_t *ci) c_psql_database_t *db; char cb_name[DATA_MAX_NAME_LEN]; - user_data_t ud; + user_data_t ud = { 0 }; static _Bool have_flush = 0; @@ -1204,8 +1201,6 @@ static int c_psql_config_database (oconfig_item_t *ci) return 1; } - memset (&ud, 0, sizeof (ud)); - db = c_psql_database_new (ci->values[0].value.string); if (db == NULL) return -1;