Merge pull request #1830 from rubenk/move-collectd-header
[collectd.git] / src / postgresql.c
index b4b4ca7..3b125ee 100644 (file)
@@ -31,6 +31,7 @@
  */
 
 #include "collectd.h"
+
 #include "common.h"
 
 #include "configfile.h"
 #include "utils_db_query.h"
 #include "utils_complain.h"
 
-#if HAVE_PTHREAD_H
-# include <pthread.h>
-#endif
-
 #include <pg_config_manual.h>
 #include <libpq-fe.h>
 
@@ -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;