X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fdbi.c;h=273cce8e1eae7d5177bcee06bfee08da3ce542eb;hb=21ab7512825cf8177d5eee5101344b45d0854610;hp=dab47d66eb1e69f9c2f8da2d376ab8eeab2860d1;hpb=1ebf2f31bd2e080e6f42de640f0a3899a61501c0;p=collectd.git diff --git a/src/dbi.c b/src/dbi.c index dab47d66..273cce8e 100644 --- a/src/dbi.c +++ b/src/dbi.c @@ -148,7 +148,7 @@ static int cdbi_result_get_field (dbi_result res, /* {{{ */ else if (src_type == DBI_TYPE_STRING) { const char *value; - + value = dbi_result_get_string_idx (res, index); if (value == NULL) sstrncpy (buffer, "", buffer_size); @@ -214,7 +214,7 @@ static void cdbi_database_free (cdbi_database_t *db) /* {{{ */ * * ... * - * + * * * Driver "mysql" * Interval 120 @@ -240,7 +240,7 @@ static int cdbi_config_add_database_driver_option (cdbi_database_t *db, /* {{{ * return (-1); } - option = (cdbi_driver_option_t *) realloc (db->driver_options, + option = realloc (db->driver_options, sizeof (*option) * (db->driver_options_num + 1)); if (option == NULL) { @@ -294,13 +294,12 @@ static int cdbi_config_add_database (oconfig_item_t *ci) /* {{{ */ return (-1); } - db = malloc (sizeof (*db)); + db = calloc (1, sizeof (*db)); if (db == NULL) { - ERROR ("dbi plugin: malloc failed."); + ERROR ("dbi plugin: calloc failed."); return (-1); } - memset (db, 0, sizeof (*db)); status = cf_util_get_string (ci, &db->name); if (status != 0) @@ -387,7 +386,7 @@ static int cdbi_config_add_database (oconfig_item_t *ci) /* {{{ */ { cdbi_database_t **temp; - temp = (cdbi_database_t **) realloc (databases, + temp = realloc (databases, sizeof (*databases) * (databases_num + 1)); if (temp == NULL) { @@ -511,7 +510,6 @@ static int cdbi_read_database_query (cdbi_database_t *db, /* {{{ */ column_names = NULL; column_values = NULL; - res = NULL; statement = udb_query_get_statement (q); assert (statement != NULL);