*/
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;
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;
if (pnumcpu != numcpu || perfcpu == NULL)
{
- if (perfcpu != NULL)
- free(perfcpu);
+ free(perfcpu);
perfcpu = malloc(numcpu * sizeof(perfstat_cpu_t));
}
pnumcpu = numcpu;
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.");
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.");
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.");
/* 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);
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;
{
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);
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));
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.");
{
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.");
if (fields[0][0] == '#')
return;
- ds = (data_set_t *) malloc (sizeof (data_set_t));
+ ds = malloc (sizeof (*ds));
if (ds == NULL)
return;
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));
{
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.");
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.");
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);
{
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;
}
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));
len = off1 + strlen (replacement) + strlen (string) - off2 + 1;
- buf = (char *)malloc (len);
+ buf = malloc (len);
if (NULL == buf)
return NULL;
{
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));
{
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);
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++)
{
counter_list_t *entry;
- entry = (counter_list_t *) malloc (sizeof (counter_list_t));
+ entry = malloc (sizeof (*entry));
if (entry == NULL)
return (NULL);
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;
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.");
}
/* Initialize `dir' */
- dir = (fc_directory_conf_t *) malloc (sizeof (*dir));
+ dir = malloc (sizeof (*dir));
if (dir == NULL)
{
ERROR ("filecount plugin: malloc failed.");
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));
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;
*nmemb = size / stsize;
- buff = (caddr_t)malloc (size);
+ buff = malloc (size);
if (buff == NULL) {
ERROR ("ipc plugin: ipc_get_info malloc failed.");
return (NULL);
}
chain_list = list;
- final = (ip_chain_t *) malloc( sizeof(temp) );
+ final = malloc(sizeof (*final));
if (final == NULL)
{
char errbuf[1024];
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.");
/* 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);
{
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");
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;
}
{
mec_match_t *m;
- m = (mec_match_t *) malloc (sizeof (*m));
+ m = malloc (sizeof (*m));
if (m == NULL)
{
ERROR ("mec_create: malloc failed.");
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.");
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.");
int status;
int i;
- m = (mt_match_t *) malloc (sizeof (*m));
+ m = malloc (sizeof (*m));
if (m == NULL)
{
ERROR ("mt_create: malloc failed.");
int status;
int i;
- m = (mv_match_t *) malloc (sizeof (*m));
+ m = malloc (sizeof (*m));
if (m == NULL)
{
ERROR ("mv_create: malloc failed.");
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.");
return (-1);
}
- db = (mysql_database_t *) malloc (sizeof (*db));
+ db = malloc (sizeof (*db));
if (db == NULL)
{
ERROR ("mysql plugin: malloc failed.");
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));
{
ir_ignorelist_t *entry;
- entry = (ir_ignorelist_t *) malloc (sizeof (ir_ignorelist_t));
+ entry = malloc (sizeof (*entry));
if (entry == NULL)
return (-1);
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);
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.");
{
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");
}
/* 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];
return (-1);
}
- db = (o_database_t *) malloc (sizeof (*db));
+ db = malloc (sizeof (*db));
if (db == NULL)
{
ERROR ("oracle plugin: malloc failed.");
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] = "";
hostlist_t *hl;
char *host;
- hl = (hostlist_t *) malloc (sizeof (hostlist_t));
+ hl = malloc (sizeof (*hl));
if (hl == NULL)
{
char errbuf[1024];
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;
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.");
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.");
{
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));
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);
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.");
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);
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));
}
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++)
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));
int status;
int i;
- data = (tn_data_t *) malloc (sizeof (*data));
+ data = malloc (sizeof (*data));
if (data == NULL)
{
ERROR ("tn_create: malloc failed.");
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.");
int status;
int i;
- data = (ts_data_t *) malloc (sizeof (*data));
+ data = malloc (sizeof (*data));
if (data == NULL)
{
ERROR ("ts_create: malloc failed.");
int status;
int i;
- data = (ts_data_t *) malloc (sizeof (*data));
+ data = malloc (sizeof (*data));
if (data == NULL)
{
ERROR ("ts_create: malloc failed.");
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.");
}
/* Allocate memory */
- entry = (vserver_list_t *) malloc (sizeof (vserver_list_t));
+ entry = malloc (sizeof (*entry));
if (entry == NULL)
{
ERROR ("teamspeak2 plugin: malloc failed.");
return (-1);
}
- th_copy = (threshold_t *) malloc (sizeof (threshold_t));
+ th_copy = malloc (sizeof (*th_copy));
if (th_copy == NULL)
{
sfree (name_copy);
pthread_exit ((void *) 1);
}
- remote_fd = (int *) malloc (sizeof (int));
+ remote_fd = malloc (sizeof (*remote_fd));
if (remote_fd == NULL)
{
char errbuf[1024];
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");
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.");
if (ignore_list_match (addr) != 0)
return;
- new = malloc (sizeof (ip_list_t));
+ new = malloc (sizeof (*new));
if (new == NULL)
{
perror ("malloc");
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;
}
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",
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;
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);
}