summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6894d84)
raw | patch | inline | side by side (parent: 6894d84)
author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Mon, 28 Mar 2016 17:12:10 +0000 (19:12 +0200) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Mon, 28 Mar 2016 17:12:10 +0000 (19:12 +0200) |
- Remove unnecessary casts
- Use the size of the variable for mallocs size
- Use the size of the variable for mallocs size
72 files changed:
diff --git a/src/barometer.c b/src/barometer.c
index 0e8deaf82fca1685c8f368850b9eb0b2cea0759b..f14ac049dab29ada5279a01d9388d621f5962eb6 100644 (file)
--- a/src/barometer.c
+++ b/src/barometer.c
*/
static int temp_list_add(temperature_list_t * list, const char * sensor)
{
- temperature_list_t * new_temp;
+ temperature_list_t *new_temp;
- new_temp = (temperature_list_t *) malloc(sizeof(*new_temp));
+ new_temp = malloc(sizeof (*new_temp));
if(new_temp == NULL)
return -1;
diff --git a/src/ceph.c b/src/ceph.c
index b1ca3b66649dce4d6e086910b89ef13f534a7d2c..04a397434d1b7c228fc5a885a424ebbb9101c230 100644 (file)
--- a/src/ceph.c
+++ b/src/ceph.c
return -ENOMEM;
}
- d->ds_names[d->ds_num] = malloc(sizeof(char) * DATA_MAX_NAME_LEN);
+ d->ds_names[d->ds_num] = malloc(DATA_MAX_NAME_LEN);
if(!d->ds_names[d->ds_num])
{
return -ENOMEM;
}
g_daemons = tmp;
- nd = malloc(sizeof(*nd));
+ nd = malloc(sizeof (*nd));
if(!nd)
{
return ENOMEM;
static int add_last(struct ceph_daemon *d, const char *ds_n, double cur_sum,
uint64_t cur_count)
{
- d->last_poll_data[d->last_idx] = malloc(1 * sizeof(struct last_data));
+ d->last_poll_data[d->last_idx] = malloc(sizeof (*d->last_poll_data[d->last_idx]));
if(!d->last_poll_data[d->last_idx])
{
return -ENOMEM;
if(!d->last_poll_data)
{
- d->last_poll_data = malloc(1 * sizeof(struct last_data *));
+ d->last_poll_data = malloc(sizeof (*d->last_poll_data));
if(!d->last_poll_data)
{
return -ENOMEM;
diff --git a/src/cpu.c b/src/cpu.c
index 7f8c9858995c7d11f3d853905e4d3e574d660822..9c432d1791d0090191842aa364c48d761b5da72e 100644 (file)
--- a/src/cpu.c
+++ b/src/cpu.c
if (pnumcpu != numcpu || perfcpu == NULL)
{
- if (perfcpu != NULL)
- free(perfcpu);
+ free(perfcpu);
perfcpu = malloc(numcpu * sizeof(perfstat_cpu_t));
}
pnumcpu = numcpu;
diff --git a/src/curl.c b/src/curl.c
index 16ae3ababc1d48c421c85c814b2eb0499edd699e..f6127a9fb11cfab3f2f4a9d73fadd7390cd078ac 100644 (file)
--- a/src/curl.c
+++ b/src/curl.c
WARNING ("curl plugin: Ignoring arguments for the `Match' block.");
}
- match = (web_match_t *) malloc (sizeof (*match));
+ match = malloc (sizeof (*match));
if (match == NULL)
{
ERROR ("curl plugin: malloc failed.");
if (wp->pass != NULL)
credentials_size += strlen (wp->pass);
- wp->credentials = (char *) malloc (credentials_size);
+ wp->credentials = malloc (credentials_size);
if (wp->credentials == NULL)
{
ERROR ("curl plugin: malloc failed.");
return (-1);
}
- page = (web_page_t *) malloc (sizeof (*page));
+ page = malloc (sizeof (*page));
if (page == NULL)
{
ERROR ("curl plugin: malloc failed.");
diff --git a/src/curl_json.c b/src/curl_json.c
index 45898c3ec1115ed9c7b6c8fd0f0c463b1370ff66..4fa6f33bc6ce1e55c213fbcfbe8bbbdd4cc75f07 100644 (file)
--- a/src/curl_json.c
+++ b/src/curl_json.c
return (-1);
}
- key = (cj_key_t *) malloc (sizeof (*key));
+ key = malloc (sizeof (*key));
if (key == NULL)
{
ERROR ("curl_json plugin: malloc failed.");
if (db->pass != NULL)
credentials_size += strlen (db->pass);
- db->credentials = (char *) malloc (credentials_size);
+ db->credentials = malloc (credentials_size);
if (db->credentials == NULL)
{
ERROR ("curl_json plugin: malloc failed.");
return (-1);
}
- db = (cj_t *) malloc (sizeof (*db));
+ db = malloc (sizeof (*db));
if (db == NULL)
{
ERROR ("curl_json plugin: malloc failed.");
diff --git a/src/curl_xml.c b/src/curl_xml.c
index 39d6fd04b3c93f5ac9bec31df153f8093203e626..ab18b78083ab58471765a32a48f55ca2e4a805d7 100644 (file)
--- a/src/curl_xml.c
+++ b/src/curl_xml.c
sfree (xpath->values);
xpath->values_len = 0;
- xpath->values = (cx_values_t *) malloc (sizeof (cx_values_t) * ci->values_num);
+ xpath->values = malloc (sizeof (cx_values_t) * ci->values_num);
if (xpath->values == NULL)
return (-1);
xpath->values_len = (size_t) ci->values_num;
if (db->pass != NULL)
credentials_size += strlen (db->pass);
- db->credentials = (char *) malloc (credentials_size);
+ db->credentials = malloc (credentials_size);
if (db->credentials == NULL)
{
ERROR ("curl_xml plugin: malloc failed.");
return (-1);
}
- db = (cx_t *) malloc (sizeof (*db));
+ db = malloc (sizeof (*db));
if (db == NULL)
{
ERROR ("curl_xml plugin: malloc failed.");
diff --git a/src/daemon/common.c b/src/daemon/common.c
index dd4f9b15ae39a5036cbb0b40f0b8c21624ee473a..2f6da95772beb5dc8f976d0ce2c79796e1bf87a5 100644 (file)
--- a/src/daemon/common.c
+++ b/src/daemon/common.c
/* Do not use `strdup' here, because it's not specified in POSIX. It's
* ``only'' an XSI extension. */
sz = strlen (s) + 1;
- r = (char *) malloc (sizeof (char) * sz);
+ r = malloc (sz);
if (r == NULL)
{
ERROR ("sstrdup: Out of memory.");
if (buffer_size < 3)
return (EINVAL);
- temp = (char *) malloc (buffer_size);
+ temp = malloc (buffer_size);
if (temp == NULL)
return (ENOMEM);
memset (temp, 0, buffer_size);
index 8a7621d2b5fb912b02d64c8c9f86456d42dbea08..5f49a9e6fc0848d1ff2975e696d3e87e39ae12b9 100644 (file)
--- a/src/daemon/configfile.c
+++ b/src/daemon/configfile.c
return (NULL);
}
- root = (oconfig_item_t *) malloc (sizeof (oconfig_item_t));
+ root = malloc (sizeof (*root));
if (root == NULL)
{
ERROR ("configfile: malloc failed.");
return (NULL);
}
- root = (oconfig_item_t *) malloc (sizeof (oconfig_item_t));
+ root = malloc (sizeof (*root));
if (root == NULL)
{
ERROR ("configfile: malloc failed.");
cf_unregister (type);
/* This pointer will be free'd in `cf_unregister' */
- if ((cf_cb = (cf_callback_t *) malloc (sizeof (cf_callback_t))) == NULL)
+ if ((cf_cb = malloc (sizeof (*cf_cb))) == NULL)
return;
cf_cb->type = type;
@@ -1084,7 +1084,7 @@ int cf_register_complex (const char *type, int (*callback) (oconfig_item_t *))
{
cf_complex_callback_t *new;
- new = (cf_complex_callback_t *) malloc (sizeof (cf_complex_callback_t));
+ new = malloc (sizeof (*new));
if (new == NULL)
return (-1);
index ecc7f165a5a1f73064aedcdaa9b41e086f24abf1..b599d70e82239cd05b812908549030c1064587cc 100644 (file)
return (NULL);
sz = strlen (orig) + 1;
- dest = (char *) malloc (sz);
+ dest = malloc (sz);
if (dest == NULL)
return (NULL);
return (-1);
}
- m = (fc_match_t *) malloc (sizeof (*m));
+ m = malloc (sizeof (*m));
if (m == NULL)
{
ERROR ("fc_config_add_match: malloc failed.");
return (-1);
}
- t = (fc_target_t *) malloc (sizeof (*t));
+ t = malloc (sizeof (*t));
if (t == NULL)
{
ERROR ("fc_config_add_target: malloc failed.");
return (-1);
}
- rule = (fc_rule_t *) malloc (sizeof (*rule));
+ rule = malloc (sizeof (*rule));
if (rule == NULL)
{
ERROR ("fc_config_add_rule: malloc failed.");
if (chain == NULL)
{
- chain = (fc_chain_t *) malloc (sizeof (*chain));
+ chain = malloc (sizeof (*chain));
if (chain == NULL)
{
ERROR ("fc_config_add_chain: malloc failed.");
DEBUG ("fc_register_match (%s);", name);
- m = (fc_match_t *) malloc (sizeof (*m));
+ m = malloc (sizeof (*m));
if (m == NULL)
return (-ENOMEM);
memset (m, 0, sizeof (*m));
DEBUG ("fc_register_target (%s);", name);
- t = (fc_target_t *) malloc (sizeof (*t));
+ t = malloc (sizeof (*t));
if (t == NULL)
return (-ENOMEM);
memset (t, 0, sizeof (*t));
diff --git a/src/daemon/meta_data.c b/src/daemon/meta_data.c
index e1d0ec5b71f17a9a284b1a37745416accece939a..10678640f94f8de4902b9eecc06567ceccc893d7 100644 (file)
--- a/src/daemon/meta_data.c
+++ b/src/daemon/meta_data.c
return (NULL);
sz = strlen (orig) + 1;
- dest = (char *) malloc (sz);
+ dest = malloc (sz);
if (dest == NULL)
return (NULL);
{
meta_entry_t *e;
- e = (meta_entry_t *) malloc (sizeof (*e));
+ e = malloc (sizeof (*e));
if (e == NULL)
{
ERROR ("md_entry_alloc: malloc failed.");
{
meta_data_t *md;
- md = (meta_data_t *) malloc (sizeof (*md));
+ md = malloc (sizeof (*md));
if (md == NULL)
{
ERROR ("meta_data_create: malloc failed.");
diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c
index e7993f1e8686b4adce2670754f9f24f82f3e9dc4..6c8b6b0ef914fa2fb7cb5e117c7ce39be242f94d 100644 (file)
--- a/src/daemon/plugin.c
+++ b/src/daemon/plugin.c
{
callback_func_t *cf;
- cf = (callback_func_t *) malloc (sizeof (*cf));
+ cf = malloc (sizeof (*cf));
if (cf == NULL)
{
ERROR ("plugin: create_register_callback: malloc failed.");
prefix_size = strlen(flush_prefix);
name_size = strlen(name);
- flush_name = malloc (sizeof(char) * (name_size + prefix_size + 1));
+ flush_name = malloc (name_size + prefix_size + 1);
if (flush_name == NULL)
{
ERROR ("plugin_flush_callback_name: malloc failed.");
if (flush_name == NULL)
return (-1);
- cb = malloc(sizeof(flush_callback_t));
+ cb = malloc(sizeof (*cb));
if (cb == NULL)
{
ERROR ("plugin_register_flush: malloc failed.");
return (-1);
}
- ds_copy = (data_set_t *) malloc (sizeof (data_set_t));
+ ds_copy = malloc (sizeof (*ds_copy));
if (ds_copy == NULL)
return (-1);
memcpy(ds_copy, ds, sizeof (data_set_t));
- ds_copy->ds = (data_source_t *) malloc (sizeof (data_source_t)
+ ds_copy->ds = malloc (sizeof (*ds_copy->ds)
* ds->ds_num);
if (ds_copy->ds == NULL)
{
return (-1);
}
- meta = (notification_meta_t *) malloc (sizeof (notification_meta_t));
+ meta = malloc (sizeof (*meta));
if (meta == NULL)
{
ERROR ("plugin_notification_meta_add: malloc failed.");
index eb50bb8a390969fcf580419b944e05b7fec537b8..3ac38f23738911f8c22e885c8b94fc346e272b1b 100644 (file)
--- a/src/daemon/types_list.c
+++ b/src/daemon/types_list.c
if (fields[0][0] == '#')
return;
- ds = (data_set_t *) malloc (sizeof (data_set_t));
+ ds = malloc (sizeof (*ds));
if (ds == NULL)
return;
index fcfbb9453c74e641d5d6c2909fdb430914884de5..bf6880caed10a0577b9a1f78f2ffa4ac3f4ede30 100644 (file)
if (compare == NULL)
return (NULL);
- if ((t = (c_avl_tree_t *) malloc (sizeof (c_avl_tree_t))) == NULL)
+ if ((t = malloc (sizeof (*t))) == NULL)
return (NULL);
t->root = NULL;
c_avl_node_t *nptr;
int cmp;
- if ((new = (c_avl_node_t *) malloc (sizeof (c_avl_node_t))) == NULL)
+ if ((new = malloc (sizeof (*new))) == NULL)
return (-1);
new->key = key;
if (t == NULL)
return (NULL);
- iter = (c_avl_iterator_t *) malloc (sizeof (c_avl_iterator_t));
+ iter = malloc (sizeof (*iter));
if (iter == NULL)
return (NULL);
memset (iter, '\0', sizeof (c_avl_iterator_t));
index 0756807334b7b4eba7bf05bb3757c3917de63878..7f0d228f095c02faf43296c0af0f4889b5231e1f 100644 (file)
--- a/src/daemon/utils_cache.c
+++ b/src/daemon/utils_cache.c
{
cache_entry_t *ce;
- ce = (cache_entry_t *) malloc (sizeof (cache_entry_t));
+ ce = malloc (sizeof (*ce));
if (ce == NULL)
{
ERROR ("utils_cache: cache_alloc: malloc failed.");
@@ -499,7 +499,7 @@ int uc_get_rate_by_name (const char *name, gauge_t **ret_values, size_t *ret_val
else
{
ret_num = ce->values_num;
- ret = (gauge_t *) malloc (ret_num * sizeof (gauge_t));
+ ret = malloc (ret_num * sizeof (*ret));
if (ret == NULL)
{
ERROR ("utils_cache: uc_get_rate_by_name: malloc failed.");
index 12688380e89739f9afd03e6440521580cf5fe74d..011b3d3d9b6527a9f2c99b635fc9a94630675395 100644 (file)
ignorelist_item_t *new;
/* create new entry */
- if ((new = malloc(sizeof(ignorelist_item_t))) == NULL )
+ if ((new = malloc(sizeof (*new))) == NULL )
{
ERROR ("cannot allocate new entry");
return (1);
index 4265286bdaf899dcb2bba34e97a712876d5455b0..40dd0eaad7563114c63936a922d3a74da8df2b1d 100644 (file)
--- a/src/daemon/utils_llist.c
+++ b/src/daemon/utils_llist.c
{
llist_t *ret;
- ret = (llist_t *) malloc (sizeof (llist_t));
+ ret = malloc (sizeof (*ret));
if (ret == NULL)
return (NULL);
{
llentry_t *e;
- e = (llentry_t *) malloc (sizeof (llentry_t));
+ e = malloc (sizeof (*e));
if (e)
{
e->key = key;
index 5083b05a7f7176886aa8016935de4e6563054c79..c1d99e15aa4f81e413ec7bc852cef630f463a721 100644 (file)
--- a/src/daemon/utils_match.c
+++ b/src/daemon/utils_match.c
}
ret_len = end - begin;
- ret = (char *) malloc (sizeof (char) * (ret_len + 1));
+ ret = malloc (ret_len + 1);
if (ret == NULL)
{
ERROR ("utils_match: match_substr: malloc failed.");
DEBUG ("utils_match: match_create_callback: regex = %s, excluderegex = %s",
regex, excluderegex);
- obj = (cu_match_t *) malloc (sizeof (cu_match_t));
+ obj = malloc (sizeof (*obj));
if (obj == NULL)
return (NULL);
memset (obj, '\0', sizeof (cu_match_t));
cu_match_value_t *user_data;
cu_match_t *obj;
- user_data = (cu_match_value_t *) malloc (sizeof (cu_match_value_t));
+ user_data = malloc (sizeof (*user_data));
if (user_data == NULL)
return (NULL);
memset (user_data, '\0', sizeof (cu_match_value_t));
index cfa1c7642f0d01b5b5bbdfb2be78dbf38bcb6968..9284f7330bac4ad8aa272cf213b545c26000815f 100644 (file)
--- a/src/daemon/utils_subst.c
+++ b/src/daemon/utils_subst.c
len = off1 + strlen (replacement) + strlen (string) - off2 + 1;
- buf = (char *)malloc (len);
+ buf = malloc (len);
if (NULL == buf)
return NULL;
index fe5dca89b891ef3b8c874b2ee7cb8d414e172409..c4b73c35dffc4c85dc218a2e3baecb1c25178d7f 100644 (file)
--- a/src/daemon/utils_tail.c
+++ b/src/daemon/utils_tail.c
{
cu_tail_t *obj;
- obj = (cu_tail_t *) malloc (sizeof (cu_tail_t));
+ obj = malloc (sizeof (*obj));
if (obj == NULL)
return (NULL);
memset (obj, '\0', sizeof (cu_tail_t));
index 8776ad11f3731f6596f5f7ee078c78c97cec53d6..c8fd05ef7672e0c991c5e1ad04357f98730be63a 100644 (file)
{
cu_tail_match_t *obj;
- obj = (cu_tail_match_t *) malloc (sizeof (cu_tail_match_t));
+ obj = malloc (sizeof (*obj));
if (obj == NULL)
return (NULL);
memset (obj, '\0', sizeof (cu_tail_match_t));
if (match == NULL)
return (-1);
- user_data = (cu_tail_match_simple_t *) malloc (sizeof (cu_tail_match_simple_t));
+ user_data = malloc (sizeof (*user_data));
if (user_data == NULL)
{
match_destroy (match);
diff --git a/src/dbi.c b/src/dbi.c
index 94d0762d261fada2a4ebda04278f43947dc0b006..dab47d66eb1e69f9c2f8da2d376ab8eeab2860d1 100644 (file)
--- a/src/dbi.c
+++ b/src/dbi.c
return (-1);
}
- db = (cdbi_database_t *) malloc (sizeof (*db));
+ db = malloc (sizeof (*db));
if (db == NULL)
{
ERROR ("dbi plugin: malloc failed.");
while ((status == 0) && (db->queries_num > 0))
{
size_t j;
- db->q_prep_areas = (udb_query_preparation_area_t **) calloc (
- db->queries_num, sizeof (*db->q_prep_areas));
+ db->q_prep_areas = calloc (db->queries_num, sizeof (*db->q_prep_areas));
if (db->q_prep_areas == NULL)
{
- WARNING ("dbi plugin: malloc failed");
+ WARNING ("dbi plugin: calloc failed");
status = -1;
break;
}
}
/* Allocate `column_names' and `column_values'. {{{ */
- column_names = (char **) calloc (column_num, sizeof (char *));
+ column_names = calloc (column_num, sizeof (*column_names));
if (column_names == NULL)
{
- ERROR ("dbi plugin: malloc failed.");
+ ERROR ("dbi plugin: calloc failed.");
BAIL_OUT (-1);
}
- column_names[0] = (char *) calloc (column_num,
- DATA_MAX_NAME_LEN * sizeof (char));
+ column_names[0] = calloc (column_num, DATA_MAX_NAME_LEN);
if (column_names[0] == NULL)
{
- ERROR ("dbi plugin: malloc failed.");
+ ERROR ("dbi plugin: calloc failed.");
BAIL_OUT (-1);
}
for (i = 1; i < column_num; i++)
column_names[i] = column_names[i - 1] + DATA_MAX_NAME_LEN;
- column_values = (char **) calloc (column_num, sizeof (char *));
+ column_values = calloc (column_num, sizeof (*column_values));
if (column_values == NULL)
{
- ERROR ("dbi plugin: malloc failed.");
+ ERROR ("dbi plugin: calloc failed.");
BAIL_OUT (-1);
}
- column_values[0] = (char *) calloc (column_num,
- DATA_MAX_NAME_LEN * sizeof (char));
+ column_values[0] = calloc (column_num, DATA_MAX_NAME_LEN);
if (column_values[0] == NULL)
{
- ERROR ("dbi plugin: malloc failed.");
+ ERROR ("dbi plugin: calloc failed.");
BAIL_OUT (-1);
}
for (i = 1; i < column_num; i++)
diff --git a/src/dns.c b/src/dns.c
index 3421c475d7e6fc49c2419332dbcd8e5d3dd09f06..f48be00968d856236a95282f5d7f56a192213290 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
{
counter_list_t *entry;
- entry = (counter_list_t *) malloc (sizeof (counter_list_t));
+ entry = malloc (sizeof (*entry));
if (entry == NULL)
return (NULL);
diff --git a/src/email.c b/src/email.c
index 81ae29c3035269513105e87a1193bdc205b9808a..8898c087020c84d465f42d1569abb193b9230890 100644 (file)
--- a/src/email.c
+++ b/src/email.c
static void type_list_incr (type_list_t *list, char *name, int incr)
{
if (NULL == list->head) {
- list->head = (type_t *)smalloc (sizeof (type_t));
+ list->head = smalloc (sizeof (*list->head));
list->head->name = sstrdup (name);
list->head->value = incr;
}
if (NULL == ptr) {
- list->tail->next = (type_t *)smalloc (sizeof (type_t));
+ list->tail->next = smalloc (sizeof (*list->tail->next));
list->tail = list->tail->next;
list->tail->name = sstrdup (name);
available_collectors = max_conns;
collectors =
- (collector_t **)smalloc (max_conns * sizeof (collector_t *));
+ smalloc (max_conns * sizeof (*collectors));
for (i = 0; i < max_conns; ++i) {
- collectors[i] = (collector_t *)smalloc (sizeof (collector_t));
+ collectors[i] = smalloc (sizeof (*collectors[i]));
collectors[i]->socket = NULL;
if (0 != (err = plugin_thread_create (&collectors[i]->thread,
for (ptr1 = l1->head, ptr2 = l2->head; NULL != ptr1;
ptr1 = ptr1->next, last = ptr2, ptr2 = ptr2->next) {
if (NULL == ptr2) {
- ptr2 = (type_t *)smalloc (sizeof (type_t));
+ ptr2 = smalloc (sizeof (*ptr2));
ptr2->name = NULL;
ptr2->next = NULL;
diff --git a/src/exec.c b/src/exec.c
index f080ad674bac793ceb27feb0f75de67d16385fb4..4c45dc158a267951cde5a8d608fe25be905f0a61 100644 (file)
--- a/src/exec.c
+++ b/src/exec.c
return (-1);
}
- pl = (program_list_t *) malloc (sizeof (program_list_t));
+ pl = malloc (sizeof (*pl));
if (pl == NULL)
{
ERROR ("exec plugin: malloc failed.");
return (-1);
}
- pl->argv = (char **) malloc (ci->values_num * sizeof (char *));
+ pl->argv = malloc (ci->values_num * sizeof (*pl->argv));
if (pl->argv == NULL)
{
ERROR ("exec plugin: malloc failed.");
if (pl->pid != 0)
continue;
- pln = (program_list_and_notification_t *) malloc (sizeof
- (program_list_and_notification_t));
+ pln = malloc (sizeof (*pln));
if (pln == NULL)
{
ERROR ("exec plugin: malloc failed.");
diff --git a/src/filecount.c b/src/filecount.c
index 9ea8af7abe2792ebc7235094cb67f37e75a668e8..7c96a48f4b9705a12878a2ab87dcb0d62a9dc8ba 100644 (file)
--- a/src/filecount.c
+++ b/src/filecount.c
}
/* Initialize `dir' */
- dir = (fc_directory_conf_t *) malloc (sizeof (*dir));
+ dir = malloc (sizeof (*dir));
if (dir == NULL)
{
ERROR ("filecount plugin: malloc failed.");
diff --git a/src/gmond.c b/src/gmond.c
index f86d8f7add6df91563d6c8cb1f0d692c9ef7e803..9b5ceb76e1600946bf06007f1126ef2e0b150cd4 100644 (file)
--- a/src/gmond.c
+++ b/src/gmond.c
return (se);
/* insert new entry */
- se = (staging_entry_t *) malloc (sizeof (*se));
+ se = malloc (sizeof (*se));
if (se == NULL)
return (NULL);
memset (se, 0, sizeof (*se));
diff --git a/src/interface.c b/src/interface.c
index 90dc139dccc0131ff7b83a8921b8333beb615c84..d05dd72309f80ffd79c6e94fbe2c9509d962afce 100644 (file)
--- a/src/interface.c
+++ b/src/interface.c
if (pnif != nif || ifstat == NULL)
{
- if (ifstat != NULL)
- free(ifstat);
- ifstat = malloc(nif * sizeof(perfstat_netinterface_t));
+ free(ifstat);
+ ifstat = malloc(nif * sizeof (*ifstat));
}
pnif = nif;
diff --git a/src/ipc.c b/src/ipc.c
index 645d4b087e735ce06d8db51fd8fa731e6345bac4..00b3a5f8657a0e8d32ab76a41acbd43502368eb0 100644 (file)
--- a/src/ipc.c
+++ b/src/ipc.c
@@ -213,7 +213,7 @@ static caddr_t ipc_get_info (cid_t cid, int cmd, int version, int stsize, int *n
*nmemb = size / stsize;
- buff = (caddr_t)malloc (size);
+ buff = malloc (size);
if (buff == NULL) {
ERROR ("ipc plugin: ipc_get_info malloc failed.");
return (NULL);
diff --git a/src/iptables.c b/src/iptables.c
index 05e3e24b92b9716612b13748d8027521c289bd54..1e35851ab7ff49f14e8208a7ee4d6fe5f11e87d0 100644 (file)
--- a/src/iptables.c
+++ b/src/iptables.c
}
chain_list = list;
- final = (ip_chain_t *) malloc( sizeof(temp) );
+ final = malloc(sizeof (*final));
if (final == NULL)
{
char errbuf[1024];
diff --git a/src/java.c b/src/java.c
index 6b92f54e966f313e907514d17569aed104312f1c..cd01534d2693fa327f5c5420010a9480cd1a4303 100644 (file)
--- a/src/java.c
+++ b/src/java.c
@@ -1801,7 +1801,7 @@ static cjni_callback_info_t *cjni_callback_info_create (JNIEnv *jvm_env, /* {{{
return (NULL);
}
- cbi = (cjni_callback_info_t *) malloc (sizeof (*cbi));
+ cbi = malloc (sizeof (*cbi));
if (cbi == NULL)
{
ERROR ("java plugin: cjni_callback_info_create: malloc failed.");
if (cjni_env == NULL)
{
/* This pointer is free'd in `cjni_jvm_env_destroy'. */
- cjni_env = (cjni_jvm_env_t *) malloc (sizeof (*cjni_env));
+ cjni_env = malloc (sizeof (*cjni_env));
if (cjni_env == NULL)
{
ERROR ("java plugin: cjni_thread_attach: malloc failed.");
/* Allocate a new callback info structure. This is going to be our user_data
* pointer. */
- cbi_ret = (cjni_callback_info_t *) malloc (sizeof (*cbi_ret));
+ cbi_ret = malloc (sizeof (*cbi_ret));
if (cbi_ret == NULL)
{
ERROR ("java plugin: cjni_match_target_create: malloc failed.");
index 77819c217b6e8ae1272415974f88480ab17710b0..aeb8f22ae7952334094e1cee4ce60f9394611cb3 100644 (file)
/* Allocate space for the char-pointers */
res.lines_num = (size_t) res.status;
res.status = 0;
- res.lines = (char **) malloc (res.lines_num * sizeof (char *));
+ res.lines = malloc (res.lines_num * sizeof (*res.lines));
if (res.lines == NULL)
{
lcc_set_errno (c, ENOMEM);
if (ret_con == NULL)
return (-1);
- c = (lcc_connection_t *) malloc (sizeof (*c));
+ c = malloc (sizeof (*c));
if (c == NULL)
return (-1);
memset (c, 0, sizeof (*c));
/* Allocate space for the values */
if (ret_values != NULL)
{
- values = (gauge_t *) malloc (values_num * sizeof (*values));
+ values = malloc (values_num * sizeof (*values));
if (values == NULL)
BAIL_OUT (ENOMEM);
}
}
ident_num = res.lines_num;
- ident = (lcc_identifier_t *) malloc (ident_num * sizeof (*ident));
+ ident = malloc (ident_num * sizeof (*ident));
if (ident == NULL)
{
lcc_response_free (&res);
index 89ccdecb9e6e935be7eb840b8ac4a135d687de28..48f0b25f54dc57807931c82f6d437352d5e457da 100644 (file)
--- a/src/liboconfig/oconfig.c
+++ b/src/liboconfig/oconfig.c
{
oconfig_item_t *ci_copy;
- ci_copy = (oconfig_item_t *) malloc (sizeof (*ci_copy));
+ ci_copy = malloc (sizeof (*ci_copy));
if (ci_copy == NULL)
{
fprintf (stderr, "malloc failed.\n");
index 803eec26205317b30c21425c9c2821a4f75321fe..57e9ddffc770041e134a670897c8036fa001ca6e 100644 (file)
--- a/src/liboconfig/parser.y
+++ b/src/liboconfig/parser.y
entire_file:
statement_list
{
- ci_root = malloc (sizeof (oconfig_item_t));
- memset (ci_root, '\0', sizeof (oconfig_item_t));
+ ci_root = malloc (sizeof (*ci_root));
+ memset (ci_root, '\0', sizeof (*ci_root));
ci_root->children = $1.statement;
ci_root->children_num = $1.statement_num;
}
| /* epsilon */
{
- ci_root = malloc (sizeof (oconfig_item_t));
- memset (ci_root, '\0', sizeof (oconfig_item_t));
+ ci_root = malloc (sizeof (*ci_root));
+ memset (ci_root, '\0', sizeof (*ci_root));
ci_root->children = NULL;
ci_root->children_num = 0;
}
index e30ff91bc7f17e6a9983a9215e53497ea8c78794..4a5dc8c06680180b75de83fcf2248e92b52d80c7 100644 (file)
{
mec_match_t *m;
- m = (mec_match_t *) malloc (sizeof (*m));
+ m = malloc (sizeof (*m));
if (m == NULL)
{
ERROR ("mec_create: malloc failed.");
diff --git a/src/match_hashed.c b/src/match_hashed.c
index ba0c47c3f30275ce422f30b6fa717b0bb0d761cf..049dd28d830b60ec6fb00ed54de011ce5515a9f6 100644 (file)
--- a/src/match_hashed.c
+++ b/src/match_hashed.c
mh_match_t *m;
int i;
- m = (mh_match_t *) malloc (sizeof (*m));
+ m = malloc (sizeof (*m));
if (m == NULL)
{
ERROR ("mh_create: malloc failed.");
diff --git a/src/match_regex.c b/src/match_regex.c
index 4fa6ce78d5d0c0007629a98e43fe4c5b3fbc2973..7429ffaf719d063e87367aaf2be42afafaf13d24 100644 (file)
--- a/src/match_regex.c
+++ b/src/match_regex.c
return (-1);
}
- re = (mr_regex_t *) malloc (sizeof (*re));
+ re = malloc (sizeof (*re));
if (re == NULL)
{
log_err ("mr_config_add_regex: malloc failed.");
int status;
int i;
- m = (mr_match_t *) malloc (sizeof (*m));
+ m = malloc (sizeof (*m));
if (m == NULL)
{
log_err ("mr_create: malloc failed.");
diff --git a/src/match_timediff.c b/src/match_timediff.c
index 996201adfab746f28883865b05f6932572e756ce..2b5f530a73620f1713e559662e98be23e1a35627 100644 (file)
--- a/src/match_timediff.c
+++ b/src/match_timediff.c
int status;
int i;
- m = (mt_match_t *) malloc (sizeof (*m));
+ m = malloc (sizeof (*m));
if (m == NULL)
{
ERROR ("mt_create: malloc failed.");
diff --git a/src/match_value.c b/src/match_value.c
index 9ffcecaae473b9bc24b49d721e5b2914ae4bcfbe..9b13aa86155ac3051fdc2de8f58a78c4e81f743c 100644 (file)
--- a/src/match_value.c
+++ b/src/match_value.c
int status;
int i;
- m = (mv_match_t *) malloc (sizeof (*m));
+ m = malloc (sizeof (*m));
if (m == NULL)
{
ERROR ("mv_create: malloc failed.");
diff --git a/src/memcachec.c b/src/memcachec.c
index 013b6c4ed6f83053fa42ace7848218fcaaf5448c..a23d4956e1e978b0910ab1ef05e8a4ed5b930de4 100644 (file)
--- a/src/memcachec.c
+++ b/src/memcachec.c
WARNING ("memcachec plugin: Ignoring arguments for the `Match' block.");
}
- match = (web_match_t *) malloc (sizeof (*match));
+ match = malloc (sizeof (*match));
if (match == NULL)
{
ERROR ("memcachec plugin: malloc failed.");
return (-1);
}
- page = (web_page_t *) malloc (sizeof (*page));
+ page = malloc (sizeof (*page));
if (page == NULL)
{
ERROR ("memcachec plugin: malloc failed.");
diff --git a/src/mysql.c b/src/mysql.c
index 3850745650a50d8425a305e1368925794038700f..029796e6c5045852f56a9fd60c39f36a517ce5d0 100644 (file)
--- a/src/mysql.c
+++ b/src/mysql.c
return (-1);
}
- db = (mysql_database_t *) malloc (sizeof (*db));
+ db = malloc (sizeof (*db));
if (db == NULL)
{
ERROR ("mysql plugin: malloc failed.");
diff --git a/src/netapp.c b/src/netapp.c
index 8a8a7fe4ea0863e3aed4f18052abd11e03c5de96..555abcc8c447be8b11d258b3b765c1a486d8247e 100644 (file)
--- a/src/netapp.c
+++ b/src/netapp.c
return d;
}
- d = malloc(sizeof(*d));
+ d = malloc (sizeof (*d));
if (d == NULL)
return (NULL);
memset (d, 0, sizeof (*d));
{
host_config_t *host;
- host = malloc(sizeof(*host));
+ host = malloc (sizeof (*host));
if (! host)
return (NULL);
memset (host, 0, sizeof (*host));
diff --git a/src/netlink.c b/src/netlink.c
index d4661ce8423091b72f5276a3a2f4fa9d3f15561c..c5f66f835cd85d130a9f7c25f2e084453c17a34a 100644 (file)
--- a/src/netlink.c
+++ b/src/netlink.c
{
ir_ignorelist_t *entry;
- entry = (ir_ignorelist_t *) malloc (sizeof (ir_ignorelist_t));
+ entry = malloc (sizeof (*entry));
if (entry == NULL)
return (-1);
diff --git a/src/network.c b/src/network.c
index 086f04eccd28700327e472e60394d0e61db0d50c..ed382a06b7a73e1ef6d8253f2d2d81e9284482e5 100644 (file)
--- a/src/network.c
+++ b/src/network.c
if (*ret_buffer_len < packet_len)
return (-1);
- pkg_values_types = (uint8_t *) malloc (num_values * sizeof (uint8_t));
+ pkg_values_types = malloc (num_values * sizeof (*pkg_values_types));
if (pkg_values_types == NULL)
{
ERROR ("network plugin: write_part_values: malloc failed.");
return (-1);
}
- pkg_values = (value_t *) malloc (num_values * sizeof (value_t));
+ pkg_values = malloc (num_values * sizeof (*pkg_values));
if (pkg_values == NULL)
{
free (pkg_values_types);
* these entries in the dispatch thread but put them in
* another list, so we don't have to allocate more and
* more of these structures. */
- ent = malloc (sizeof (receive_list_entry_t));
+ ent = malloc (sizeof (*ent));
if (ent == NULL)
{
ERROR ("network plugin: malloc failed.");
break;
}
memset (ent, 0, sizeof (receive_list_entry_t));
- ent->data = malloc (network_config_packet_size);
+ ent->data = malloc (*ent->data);
if (ent->data == NULL)
{
sfree (ent);
diff --git a/src/nut.c b/src/nut.c
index d5ecc98de12b13a811f7e36fc131eaf36dfb6c19..9540d7c47fdf3dd4f4b146454ea22ab47bc49cb7 100644 (file)
--- a/src/nut.c
+++ b/src/nut.c
DEBUG ("nut plugin: nut_add_ups (name = %s);", name);
- ups = (nut_ups_t *) malloc (sizeof (nut_ups_t));
+ ups = malloc (sizeof (*ups));
if (ups == NULL)
{
ERROR ("nut plugin: nut_add_ups: malloc failed.");
/* (Re-)Connect if we have no connection */
if (ups->conn == NULL)
{
- ups->conn = (collectd_upsconn_t *) malloc (sizeof (collectd_upsconn_t));
+ ups->conn = malloc (sizeof (*ups->conn));
if (ups->conn == NULL)
{
ERROR ("nut plugin: malloc failed.");
diff --git a/src/onewire.c b/src/onewire.c
index 3c441ecb3493791d4d650b7667f3d355ccdf9109..42bd1eb8213c5e0700584bea21c381711900a1e6 100644 (file)
--- a/src/onewire.c
+++ b/src/onewire.c
{
regmatch_t pmatch[3];
size_t nmatch = 3;
- direct_access_element_t *element = NULL;
+ direct_access_element_t *element;
DEBUG ("onewire plugin: direct_list_insert <%s>", config);
- element = (direct_access_element_t *) malloc (sizeof(*element));
+ element = malloc (sizeof (*element));
if (element == NULL)
{
ERROR ("onewire plugin: direct_list_insert - cannot allocate element");
diff --git a/src/openvpn.c b/src/openvpn.c
index 8bccce3883a88664598416dbc5a7e0c676c9a051..ec76a7aa66b5f69f749c6add9adfd15adf8187be 100644 (file)
--- a/src/openvpn.c
+++ b/src/openvpn.c
}
/* create a new vpn element since file, version and name are ok */
- temp = (vpn_status_t *) malloc (sizeof (vpn_status_t));
+ temp = malloc (sizeof (*temp));
if (temp == NULL)
{
char errbuf[1024];
diff --git a/src/oracle.c b/src/oracle.c
index ab0812b703ec441c745d4afbe2bcdaf2ca79025f..84d9ed4952d2c1837f5cb783fc85226f3193a221 100644 (file)
--- a/src/oracle.c
+++ b/src/oracle.c
return (-1);
}
- db = (o_database_t *) malloc (sizeof (*db));
+ db = malloc (sizeof (*db));
if (db == NULL)
{
ERROR ("oracle plugin: malloc failed.");
diff --git a/src/perl.c b/src/perl.c
index c25bfe897870a8a83457c1c60e91b59c6767aa3e..920e7b3f015a60c3c3c3aa349c3a2d711a3d961b 100644 (file)
--- a/src/perl.c
+++ b/src/perl.c
return -1;
}
- ds->ds = (data_source_t *)smalloc ((len + 1) * sizeof (data_source_t));
+ ds->ds = smalloc ((len + 1) * sizeof (*ds->ds));
ds->ds_num = len + 1;
for (i = 0; i <= len; ++i) {
hash = (HV *)SvRV (*tmp);
- *m = (notification_meta_t *)smalloc (sizeof (**m));
+ *m = smalloc (sizeof (**m));
if (NULL == (tmp = hv_fetch (hash, "name", 4, 0))) {
log_warn ("av2notification_meta: Skipping invalid "
assert (NULL != perl_threads);
- t = (c_ithread_t *)smalloc (sizeof (c_ithread_t));
+ t = smalloc (sizeof (*t));
memset (t, 0, sizeof (c_ithread_t));
t->interp = (NULL == base)
return -1;
}
- data = (pfc_user_data_t *)smalloc (sizeof (*data));
+ data = smalloc (sizeof (*data));
data->name = sstrdup (ci->values[0].value.string);
data->user_data = newSV (0);
#endif
PERL_SYS_INIT3 (&argc, &argv, &environ);
- perl_threads = (c_ithread_list_t *)smalloc (sizeof (c_ithread_list_t));
+ perl_threads = smalloc (sizeof (*perl_threads));
memset (perl_threads, 0, sizeof (c_ithread_list_t));
pthread_mutex_init (&perl_threads->mutex, NULL);
perl_argv[perl_argc - 1] = "-d";
}
else {
- perl_argv[perl_argc - 1] = (char *)smalloc (strlen (value) + 4);
+ perl_argv[perl_argc - 1] = smalloc (strlen (value) + 4);
sstrncpy (perl_argv[perl_argc - 1], "-d:", 4);
sstrncpy (perl_argv[perl_argc - 1] + 3, value, strlen (value) + 1);
}
exit (3);
}
- perl_argv[perl_argc - 1] = (char *)smalloc (strlen (value) + 3);
+ perl_argv[perl_argc - 1] = smalloc (strlen (value) + 3);
sstrncpy(perl_argv[perl_argc - 1], "-I", 3);
sstrncpy(perl_argv[perl_argc - 1] + 2, value, strlen (value) + 1);
void module_register (void)
{
perl_argc = 4;
- perl_argv = (char **)smalloc ((perl_argc + 1) * sizeof (char *));
+ perl_argv = smalloc ((perl_argc + 1) * sizeof (*perl_argv));
/* default options for the Perl interpreter */
perl_argv[0] = "";
diff --git a/src/ping.c b/src/ping.c
index da63d3a58c7bb9707b0b0d5763f0ee579b2c4dd5..b6b2b688cddbf48c1341c9e6c4ceb1c9cfa615f9 100644 (file)
--- a/src/ping.c
+++ b/src/ping.c
hostlist_t *hl;
char *host;
- hl = (hostlist_t *) malloc (sizeof (hostlist_t));
+ hl = malloc (sizeof (*hl));
if (hl == NULL)
{
char errbuf[1024];
diff --git a/src/postgresql.c b/src/postgresql.c
index 79226830cb810c68579852165c889a3b176731e2..d532906cc6063c499ebc7f32fccd6d97b78c53a9 100644 (file)
--- a/src/postgresql.c
+++ b/src/postgresql.c
c_psql_database_t **tmp;
c_psql_database_t *db;
- db = (c_psql_database_t *)malloc (sizeof(*db));
+ db = malloc (sizeof(*db));
if (NULL == db) {
log_err ("Out of memory.");
return NULL;
diff --git a/src/powerdns.c b/src/powerdns.c
index ab62dcfdd646ef43077eeb9ce7ac5d17c789fcf7..e80ca8a538cbf98e3555634887e5bd20c5a61a68 100644 (file)
--- a/src/powerdns.c
+++ b/src/powerdns.c
return (-1);
assert (buffer_size > 0);
- buffer = (char *) malloc (buffer_size);
+ buffer = malloc (buffer_size);
if (buffer == NULL)
{
FUNC_ERROR ("malloc");
return (-1);
}
- item = (list_item_t *) malloc (sizeof (list_item_t));
+ item = malloc (sizeof (*item));
if (item == NULL)
{
ERROR ("powerdns plugin: malloc failed.");
diff --git a/src/processes.c b/src/processes.c
index d0d736154281f7f9819825d346c1a16b1e44b45d..d2c0f44c0717a2cbee6df9149b142c6b3f24f006 100644 (file)
--- a/src/processes.c
+++ b/src/processes.c
procstat_t *ptr;
int status;
- new = (procstat_t *) malloc (sizeof (procstat_t));
+ new = malloc (sizeof (*new));
if (new == NULL)
{
ERROR ("processes plugin: ps_list_register: malloc failed.");
if (regexp != NULL)
{
DEBUG ("ProcessMatch: adding \"%s\" as criteria to process %s.", regexp, name);
- new->re = (regex_t *) malloc (sizeof (regex_t));
+ new->re = malloc (sizeof (*new->re));
if (new->re == NULL)
{
ERROR ("processes plugin: ps_list_register: malloc failed.");
@@ -410,7 +410,7 @@ static void ps_list_add (const char *name, const char *cmdline, procstat_entry_t
{
procstat_entry_t *new;
- new = (procstat_entry_t *) malloc (sizeof (procstat_entry_t));
+ new = malloc (sizeof (*new));
if (new == NULL)
return;
memset (new, 0, sizeof (procstat_entry_t));
diff --git a/src/rrdtool.c b/src/rrdtool.c
index fd5fb56334346e406b7a1747b5e41ab2459f7722..6b44f67e48e36757cdd34f4dd8334873fb109aac 100644 (file)
--- a/src/rrdtool.c
+++ b/src/rrdtool.c
assert (template == NULL);
new_argc = 2 + argc;
- new_argv = (char **) malloc ((new_argc + 1) * sizeof (char *));
+ new_argv = malloc ((new_argc + 1) * sizeof (*new_argv));
if (new_argv == NULL)
{
ERROR ("rrdtool plugin: malloc failed.");
{
rrd_queue_t *queue_entry;
- queue_entry = (rrd_queue_t *) malloc (sizeof (rrd_queue_t));
+ queue_entry = malloc (sizeof (*queue_entry));
if (queue_entry == NULL)
return (-1);
diff --git a/src/sensors.c b/src/sensors.c
index c678dec99c2fbdb5e544bfded5fd5a8327173c1e..3b453b15ae1d77e203f95ac3414dfd71f15caca5 100644 (file)
--- a/src/sensors.c
+++ b/src/sensors.c
continue;
}
- fl = (featurelist_t *) malloc (sizeof (featurelist_t));
+ fl = malloc (sizeof (*fl));
if (fl == NULL)
{
ERROR ("sensors plugin: malloc failed.");
&& (subfeature->type != SENSORS_SUBFEATURE_POWER_INPUT))
continue;
- fl = (featurelist_t *) malloc (sizeof (featurelist_t));
+ fl = malloc (sizeof (*fl));
if (fl == NULL)
{
ERROR ("sensors plugin: malloc failed.");
diff --git a/src/sigrok.c b/src/sigrok.c
index ad5c70c0b3eed5cfc5293c7348fcbddf7144b6b1..4e61f946f0230874074a222986e494b16fc1dd9d 100644 (file)
--- a/src/sigrok.c
+++ b/src/sigrok.c
struct config_device *cfdev;
int i;
- if (!(cfdev = malloc(sizeof(struct config_device)))) {
+ if (!(cfdev = malloc(sizeof(*cfdev)))) {
ERROR("sigrok plugin: malloc() failed.");
return -1;
}
drvopts = NULL;
if (cfdev->conn) {
- if (!(src = malloc(sizeof(struct sr_config))))
+ if (!(src = malloc(sizeof(*src))))
return -1;
src->key = SR_CONF_CONN;
src->data = g_variant_new_string(cfdev->conn);
drvopts = g_slist_append(drvopts, src);
}
if (cfdev->serialcomm) {
- if (!(src = malloc(sizeof(struct sr_config))))
+ if (!(src = malloc(sizeof(*src))))
return -1;
src->key = SR_CONF_SERIALCOMM;
src->data = g_variant_new_string(cfdev->serialcomm);
diff --git a/src/snmp.c b/src/snmp.c
index 3ccf60c3fd8ff638ab90aaa21f8eafcbb5223261..e1f1f7549f2d18797f816465d8cf2237f34ac05b 100644 (file)
--- a/src/snmp.c
+++ b/src/snmp.c
@@ -310,7 +310,7 @@ static int csnmp_config_add_data_values (data_definition_t *dd, oconfig_item_t *
sfree (dd->values);
dd->values_len = 0;
- dd->values = (oid_t *) malloc (sizeof (oid_t) * ci->values_num);
+ dd->values = malloc (sizeof (*dd->values) * ci->values_num);
if (dd->values == NULL)
return (-1);
dd->values_len = (size_t) ci->values_num;
int status = 0;
int i;
- dd = (data_definition_t *) malloc (sizeof (data_definition_t));
+ dd = malloc (sizeof (*dd));
if (dd == NULL)
return (-1);
memset (dd, '\0', sizeof (data_definition_t));
char cb_name[DATA_MAX_NAME_LEN];
user_data_t cb_data;
- hd = (host_definition_t *) malloc (sizeof (host_definition_t));
+ hd = malloc (sizeof (*hd));
if (hd == NULL)
return (-1);
memset (hd, '\0', sizeof (host_definition_t));
@@ -1710,7 +1710,7 @@ static int csnmp_read_value (host_definition_t *host, data_definition_t *data)
}
vl.values_len = ds->ds_num;
- vl.values = (value_t *) malloc (sizeof (value_t) * vl.values_len);
+ vl.values = malloc (sizeof (*vl.values) * vl.values_len);
if (vl.values == NULL)
return (-1);
for (i = 0; i < vl.values_len; i++)
diff --git a/src/tail_csv.c b/src/tail_csv.c
index bb9b58aceaa1edc459bbf7220f581c5e796997db..15c083ea40d29c52f9b8667d8920d171d8c1d2d1 100644 (file)
--- a/src/tail_csv.c
+++ b/src/tail_csv.c
int status;
int i;
- md = (metric_definition_t *)malloc(sizeof(*md));
+ md = malloc(sizeof(*md));
if (md == NULL)
return (-1);
memset(md, 0, sizeof(*md));
index 14fb5418addc659a5c429c03160ff3ef8e84871a..d850a684907c0b9c960d8c432f2465110bced39b 100644 (file)
int status;
int i;
- data = (tn_data_t *) malloc (sizeof (*data));
+ data = malloc (sizeof (*data));
if (data == NULL)
{
ERROR ("tn_create: malloc failed.");
diff --git a/src/target_replace.c b/src/target_replace.c
index bd8f9e5c51d443650545bc94325fe53df25233e3..2166746c1246e99657739856994edc8286fbd083 100644 (file)
--- a/src/target_replace.c
+++ b/src/target_replace.c
return (NULL);
sz = strlen (orig) + 1;
- dest = (char *) malloc (sz);
+ dest = malloc (sz);
if (dest == NULL)
return (NULL);
return (-1);
}
- act = (tr_action_t *) malloc (sizeof (*act));
+ act = malloc (sizeof (*act));
if (act == NULL)
{
ERROR ("tr_config_add_action: malloc failed.");
int status;
int i;
- data = (tr_data_t *) malloc (sizeof (*data));
+ data = malloc (sizeof (*data));
if (data == NULL)
{
ERROR ("tr_create: malloc failed.");
diff --git a/src/target_scale.c b/src/target_scale.c
index 6169fa05d585ce4c7a97abc6c882b80dbbeb78db..b667ed13ed618ae243b0084ca6778452c42253a8 100644 (file)
--- a/src/target_scale.c
+++ b/src/target_scale.c
int status;
int i;
- data = (ts_data_t *) malloc (sizeof (*data));
+ data = malloc (sizeof (*data));
if (data == NULL)
{
ERROR ("ts_create: malloc failed.");
diff --git a/src/target_set.c b/src/target_set.c
index daeaf8be62f7c2d9779b66f2643dd0e447ac6bd5..a676a3d1326eb06c87f9c46ea334f733a3838939 100644 (file)
--- a/src/target_set.c
+++ b/src/target_set.c
int status;
int i;
- data = (ts_data_t *) malloc (sizeof (*data));
+ data = malloc (sizeof (*data));
if (data == NULL)
{
ERROR ("ts_create: malloc failed.");
diff --git a/src/tcpconns.c b/src/tcpconns.c
index 5b47ff5354a090167992024e2d8ddfffebaec728..96221b1975164d7913f24ade2177130e576bedf2 100644 (file)
--- a/src/tcpconns.c
+++ b/src/tcpconns.c
if ((ret == NULL) && (create != 0))
{
- ret = (port_entry_t *) malloc (sizeof (port_entry_t));
+ ret = malloc (sizeof (*ret));
if (ret == NULL)
return (NULL);
memset (ret, '\0', sizeof (port_entry_t));
return (-1);
}
- buffer = (char *) malloc (buffer_len);
+ buffer = malloc (buffer_len);
if (buffer == NULL)
{
ERROR ("tcpconns plugin: malloc failed.");
diff --git a/src/teamspeak2.c b/src/teamspeak2.c
index 058eb7c38362a7cc972ca609556698e1537933f6..345f57e0d6a5c534fe57d3a946cd6555e95f9e72 100644 (file)
--- a/src/teamspeak2.c
+++ b/src/teamspeak2.c
}
/* Allocate memory */
- entry = (vserver_list_t *) malloc (sizeof (vserver_list_t));
+ entry = malloc (sizeof (*entry));
if (entry == NULL)
{
ERROR ("teamspeak2 plugin: malloc failed.");
diff --git a/src/threshold.c b/src/threshold.c
index ed8312992b437c9984d6885309bc972f1450fb4d..624ab7a91dd7c14b7112e9c2884bff46c636f8d1 100644 (file)
--- a/src/threshold.c
+++ b/src/threshold.c
return (-1);
}
- th_copy = (threshold_t *) malloc (sizeof (threshold_t));
+ th_copy = malloc (sizeof (*th_copy));
if (th_copy == NULL)
{
sfree (name_copy);
diff --git a/src/unixsock.c b/src/unixsock.c
index 795f7abe2120f7e4d4930895f9c1af014a7addeb..1840e34c45a157825fd8a9b8052a1b56500480ca 100644 (file)
--- a/src/unixsock.c
+++ b/src/unixsock.c
pthread_exit ((void *) 1);
}
- remote_fd = (int *) malloc (sizeof (int));
+ remote_fd = malloc (sizeof (*remote_fd));
if (remote_fd == NULL)
{
char errbuf[1024];
diff --git a/src/utils_cmd_putval.c b/src/utils_cmd_putval.c
index 43244f6185cad30df9561aafcee746f1171a28bc..69af2e4ae97c663fcecae4bd5ffe884cd658e09a 100644 (file)
--- a/src/utils_cmd_putval.c
+++ b/src/utils_cmd_putval.c
sfree (identifier_copy);
vl.values_len = ds->ds_num;
- vl.values = (value_t *) malloc (vl.values_len * sizeof (value_t));
+ vl.values = malloc (vl.values_len * sizeof (*vl.values));
if (vl.values == NULL)
{
print_to_socket (fh, "-1 malloc failed.\n");
diff --git a/src/utils_db_query.c b/src/utils_db_query.c
index c7be9f0d49445b8efe6e390885e535678d7e3424..d003e7fa389211b81026932819612970f7728875 100644 (file)
--- a/src/utils_db_query.c
+++ b/src/utils_db_query.c
ci->values_num, (ci->values_num == 1) ? "" : "s");
}
- r = (udb_result_t *) malloc (sizeof (*r));
+ r = malloc (sizeof (*r));
if (r == NULL)
{
ERROR ("db query utils: malloc failed.");
return (-1);
}
- q = (udb_query_t *) malloc (sizeof (*q));
+ q = malloc (sizeof (*q));
if (q == NULL)
{
ERROR ("db query utils: malloc failed.");
diff --git a/src/utils_dns.c b/src/utils_dns.c
index 2c7a59d343fb938ea7017c162317791830dbf646..991d346a4e4d034dade4423ea3ec9776747d28a4 100644 (file)
--- a/src/utils_dns.c
+++ b/src/utils_dns.c
if (ignore_list_match (addr) != 0)
return;
- new = malloc (sizeof (ip_list_t));
+ new = malloc (sizeof (*new));
if (new == NULL)
{
perror ("malloc");
diff --git a/src/utils_mount.c b/src/utils_mount.c
index 752d2e158a597e2b3b9e893d57c2d8267d1c71de..ecf011d80d751e4f1c565fb2337136bf651cbd45 100644 (file)
--- a/src/utils_mount.c
+++ b/src/utils_mount.c
return (NULL);
}
- if ((buf = (STRUCT_STATFS *) malloc (bufsize * sizeof (STRUCT_STATFS)))
- == NULL)
+ if ((buf = malloc (bufsize * sizeof (*buf))) == NULL)
return (NULL);
memset (buf, '\0', bufsize * sizeof (STRUCT_STATFS));
for (i = 0; i < num; i++)
{
- if ((new = malloc (sizeof (cu_mount_t))) == NULL)
+ if ((new = malloc (sizeof (*new))) == NULL)
break;
memset (new, '\0', sizeof (cu_mount_t));
while (getmntent (fp, &mt) == 0)
{
- if ((new = malloc (sizeof (cu_mount_t))) == NULL)
+ if ((new = malloc (sizeof (*new))) == NULL)
break;
memset (new, '\0', sizeof (cu_mount_t));
while (getmntent_r (fp, &me, mntbuf, sizeof (mntbuf) ))
{
- if ((new = malloc (sizeof (cu_mount_t))) == NULL)
+ if ((new = malloc (sizeof (*new))) == NULL)
break;
memset (new, '\0', sizeof (cu_mount_t));
while ((me = getmntent (fp)) != NULL)
{
- if ((new = malloc (sizeof (cu_mount_t))) == NULL)
+ if ((new = malloc (sizeof (*new))) == NULL)
break;
memset (new, '\0', sizeof (cu_mount_t));
if((p-r) == 1) {
return NULL;
}
- m = (char *)smalloc(p-r+1);
+ m = smalloc(p-r+1);
sstrncpy(m, r, p-r+1);
return m;
}
diff --git a/src/utils_rrdcreate.c b/src/utils_rrdcreate.c
index 06e4f21b7acfc517a0445ed64627ab0ca0b21f36..44c2386f16ad74775a9bcabaaa09d497658343b3 100644 (file)
--- a/src/utils_rrdcreate.c
+++ b/src/utils_rrdcreate.c
char last_up_str[16];
new_argc = 6 + argc;
- new_argv = (char **) malloc ((new_argc + 1) * sizeof (char *));
+ new_argv = malloc ((new_argc + 1) * sizeof (*new_argv));
if (new_argv == NULL)
{
ERROR ("rrdtool plugin: malloc failed.");
argc = ds_num + rra_num;
- if ((argv = (char **) malloc (sizeof (char *) * (argc + 1))) == NULL)
+ if ((argv = malloc (sizeof (*argv) * (argc + 1))) == NULL)
{
char errbuf[1024];
ERROR ("cu_rrd_create_file failed: %s",
diff --git a/src/virt.c b/src/virt.c
index 79d46826997d2222590839769137a0ea28155c34..bbf5afc79bbac7a6c2db3605d75174ea07b6797d 100644 (file)
--- a/src/virt.c
+++ b/src/virt.c
int *domids;
/* Get list of domains. */
- domids = malloc (sizeof (int) * n);
+ domids = malloc (sizeof (*domids) * n);
if (domids == 0) {
ERROR (PLUGIN_NAME " plugin: malloc failed.");
return -1;
diff --git a/src/zone.c b/src/zone.c
index 15eae6a222fa942116841c36c0dd20f6676417e1..52dc55395bbd4edfc9d9eca1ad7ab636ffec15b7 100644 (file)
--- a/src/zone.c
+++ b/src/zone.c
zoneid_t *key = NULL;
if (c_avl_get(tree, (void **)&zoneid, (void **)&ret)) {
- if (!(ret = malloc(sizeof(zone_stats_t)))) {
+ if (!(ret = malloc(sizeof(*ret)))) {
WARNING("zone plugin: no memory");
return(NULL);
}
- if (!(key = malloc(sizeof(zoneid_t)))) {
+ if (!(key = malloc(sizeof(*key)))) {
WARNING("zone plugin: no memory");
return(NULL);
}