summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 04d03d3)
raw | patch | inline | side by side (parent: 04d03d3)
author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Mon, 28 Mar 2016 17:56:13 +0000 (19:56 +0200) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 1 Apr 2016 13:39:42 +0000 (15:39 +0200) |
14 files changed:
diff --git a/src/daemon/common.c b/src/daemon/common.c
index 2f6da95772beb5dc8f976d0ce2c79796e1bf87a5..7b7353d96685d60b8bbe8fd951fb35f6e67b13cb 100644 (file)
--- a/src/daemon/common.c
+++ b/src/daemon/common.c
return (strdup (static_buffer));
/* Allocate a buffer large enough to hold the string. */
- alloc_buffer = malloc (alloc_buffer_size);
+ alloc_buffer = calloc (1, alloc_buffer_size);
if (alloc_buffer == NULL)
return (NULL);
- memset (alloc_buffer, 0, alloc_buffer_size);
/* Print again into this new buffer. */
va_start (ap, format);
if (buffer_size < 3)
return (EINVAL);
- temp = malloc (buffer_size);
+ temp = calloc (1, buffer_size);
if (temp == NULL)
return (ENOMEM);
- memset (temp, 0, buffer_size);
temp[0] = '"';
j = 1;
index 5f49a9e6fc0848d1ff2975e696d3e87e39ae12b9..78d4eea83fe24b4f203b74ccab3ca0185c73b776 100644 (file)
--- a/src/daemon/configfile.c
+++ b/src/daemon/configfile.c
return (NULL);
}
- root = malloc (sizeof (*root));
+ root = calloc (1, sizeof (*root));
if (root == NULL)
{
- ERROR ("configfile: malloc failed.");
+ ERROR ("configfile: calloc failed.");
closedir (dh);
return (NULL);
}
- memset (root, 0, sizeof (oconfig_item_t));
while ((de = readdir (dh)) != NULL)
{
return (NULL);
}
- root = malloc (sizeof (*root));
+ root = calloc (1, sizeof (*root));
if (root == NULL)
{
- ERROR ("configfile: malloc failed.");
+ ERROR ("configfile: calloc failed.");
return (NULL);
}
- memset (root, '\0', sizeof (oconfig_item_t));
/* wordexp() might return a sorted list already. That's not
* documented though, so let's make sure we get what we want. */
index b599d70e82239cd05b812908549030c1064587cc..babf39960232cf6acbc0bb73d4286ab366ab5a3f 100644 (file)
return (-1);
}
- m = malloc (sizeof (*m));
+ m = calloc (1, sizeof (*m));
if (m == NULL)
{
- ERROR ("fc_config_add_match: malloc failed.");
+ ERROR ("fc_config_add_match: calloc failed.");
return (-1);
}
- memset (m, 0, sizeof (*m));
sstrncpy (m->name, ptr->name, sizeof (m->name));
memcpy (&m->proc, &ptr->proc, sizeof (m->proc));
return (-1);
}
- t = malloc (sizeof (*t));
+ t = calloc (1, sizeof (*t));
if (t == NULL)
{
- ERROR ("fc_config_add_target: malloc failed.");
+ ERROR ("fc_config_add_target: calloc failed.");
return (-1);
}
- memset (t, 0, sizeof (*t));
sstrncpy (t->name, ptr->name, sizeof (t->name));
memcpy (&t->proc, &ptr->proc, sizeof (t->proc));
return (-1);
}
- rule = malloc (sizeof (*rule));
+ rule = calloc (1, sizeof (*rule));
if (rule == NULL)
{
- ERROR ("fc_config_add_rule: malloc failed.");
+ ERROR ("fc_config_add_rule: calloc failed.");
return (-1);
}
- memset (rule, 0, sizeof (*rule));
- rule->next = NULL;
if (ci->values_num == 1)
{
if (chain == NULL)
{
- chain = malloc (sizeof (*chain));
+ chain = calloc (1, sizeof (*chain));
if (chain == NULL)
{
- ERROR ("fc_config_add_chain: malloc failed.");
+ ERROR ("fc_config_add_chain: calloc failed.");
return (-1);
}
- memset (chain, 0, sizeof (*chain));
sstrncpy (chain->name, ci->values[0].value.string, sizeof (chain->name));
- chain->rules = NULL;
- chain->targets = NULL;
- chain->next = NULL;
}
for (i = 0; i < ci->children_num; i++)
DEBUG ("fc_register_match (%s);", name);
- m = malloc (sizeof (*m));
+ m = calloc (1, sizeof (*m));
if (m == NULL)
return (-ENOMEM);
- memset (m, 0, sizeof (*m));
sstrncpy (m->name, name, sizeof (m->name));
memcpy (&m->proc, &proc, sizeof (m->proc));
- m->next = NULL;
if (match_list_head == NULL)
{
DEBUG ("fc_register_target (%s);", name);
- t = malloc (sizeof (*t));
+ t = calloc (1, sizeof (*t));
if (t == NULL)
return (-ENOMEM);
- memset (t, 0, sizeof (*t));
sstrncpy (t->name, name, sizeof (t->name));
memcpy (&t->proc, &proc, sizeof (t->proc));
- t->next = NULL;
if (target_list_head == NULL)
{
diff --git a/src/daemon/meta_data.c b/src/daemon/meta_data.c
index 10678640f94f8de4902b9eecc06567ceccc893d7..cb8a195c8a29516784239b131b708a885cca5b45 100644 (file)
--- a/src/daemon/meta_data.c
+++ b/src/daemon/meta_data.c
{
meta_entry_t *e;
- e = malloc (sizeof (*e));
+ e = calloc (1, sizeof (*e));
if (e == NULL)
{
- ERROR ("md_entry_alloc: malloc failed.");
+ ERROR ("md_entry_alloc: calloc failed.");
return (NULL);
}
- memset (e, 0, sizeof (*e));
e->key = md_strdup (key);
if (e->key == NULL)
{
meta_data_t *md;
- md = malloc (sizeof (*md));
+ md = calloc (1, sizeof (*md));
if (md == NULL)
{
- ERROR ("meta_data_create: malloc failed.");
+ ERROR ("meta_data_create: calloc failed.");
return (NULL);
}
- memset (md, 0, sizeof (*md));
- md->head = NULL;
pthread_mutex_init (&md->lock, /* attr = */ NULL);
return (md);
diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c
index 6c8b6b0ef914fa2fb7cb5e117c7ce39be242f94d..e593939545c7c832bf036db561ed9f8a389fe1ae 100644 (file)
--- a/src/daemon/plugin.c
+++ b/src/daemon/plugin.c
{
callback_func_t *cf;
- cf = malloc (sizeof (*cf));
+ cf = calloc (1, sizeof (*cf));
if (cf == NULL)
{
- ERROR ("plugin: create_register_callback: malloc failed.");
+ ERROR ("plugin: create_register_callback: calloc failed.");
return (-1);
}
- memset (cf, 0, sizeof (*cf));
cf->cf_callback = callback;
if (ud == NULL)
read_func_t *rf;
int status;
- rf = malloc (sizeof (*rf));
+ rf = calloc (1, sizeof (*rf));
if (rf == NULL)
{
- ERROR ("plugin_register_read: malloc failed.");
+ ERROR ("plugin_register_read: calloc failed.");
return (ENOMEM);
}
- memset (rf, 0, sizeof (read_func_t));
rf->rf_callback = (void *) callback;
rf->rf_udata.data = NULL;
rf->rf_udata.free_func = NULL;
read_func_t *rf;
int status;
- rf = malloc (sizeof (*rf));
+ rf = calloc (1,sizeof (*rf));
if (rf == NULL)
{
- ERROR ("plugin_register_complex_read: malloc failed.");
+ ERROR ("plugin_register_complex_read: calloc failed.");
return (ENOMEM);
}
- memset (rf, 0, sizeof (read_func_t));
rf->rf_callback = (void *) callback;
if (group != NULL)
sstrncpy (rf->rf_group, group, sizeof (rf->rf_group));
return (-1);
}
- meta = malloc (sizeof (*meta));
+ meta = calloc (1, sizeof (*meta));
if (meta == NULL)
{
- ERROR ("plugin_notification_meta_add: malloc failed.");
+ ERROR ("plugin_notification_meta_add: calloc failed.");
return (-1);
}
- memset (meta, 0, sizeof (notification_meta_t));
sstrncpy (meta->name, name, sizeof (meta->name));
meta->type = type;
index 3ac38f23738911f8c22e885c8b94fc346e272b1b..de6fce3eed11e6251aed251041694484072e7e62 100644 (file)
--- a/src/daemon/types_list.c
+++ b/src/daemon/types_list.c
if (fields[0][0] == '#')
return;
- ds = malloc (sizeof (*ds));
+ ds = calloc (1, sizeof (*ds));
if (ds == NULL)
return;
- memset (ds, '\0', sizeof (data_set_t));
-
sstrncpy (ds->type, fields[0], sizeof (ds->type));
ds->ds_num = fields_num - 1;
index bf6880caed10a0577b9a1f78f2ffa4ac3f4ede30..1680c41fe37fd8dd1fbc51312c47a9cff2aca4b7 100644 (file)
if (t == NULL)
return (NULL);
- iter = malloc (sizeof (*iter));
+ iter = calloc (1, sizeof (*iter));
if (iter == NULL)
return (NULL);
- memset (iter, '\0', sizeof (c_avl_iterator_t));
iter->tree = t;
return (iter);
index 7f0d228f095c02faf43296c0af0f4889b5231e1f..e1cfac98f4ff0d39c184fc0c4d728bee421fda54 100644 (file)
--- a/src/daemon/utils_cache.c
+++ b/src/daemon/utils_cache.c
{
cache_entry_t *ce;
- ce = malloc (sizeof (*ce));
+ ce = calloc (1, sizeof (*ce));
if (ce == NULL)
{
- ERROR ("utils_cache: cache_alloc: malloc failed.");
+ ERROR ("utils_cache: cache_alloc: calloc failed.");
return (NULL);
}
- memset (ce, '\0', sizeof (cache_entry_t));
ce->values_num = values_num;
ce->values_gauge = calloc (values_num, sizeof (*ce->values_gauge));
index 1b5dca736ba59da0cf05a81ecf4a336dd378bbca..ae502c90ea7736a50e65972fc1a1917f7fa833c5 100644 (file)
--- a/src/daemon/utils_heap.c
+++ b/src/daemon/utils_heap.c
if (compare == NULL)
return (NULL);
- h = malloc (sizeof (*h));
+ h = calloc (1, sizeof (*h));
if (h == NULL)
return (NULL);
- memset (h, 0, sizeof (*h));
pthread_mutex_init (&h->lock, /* attr = */ NULL);
h->compare = compare;
-
+
h->list = NULL;
h->list_len = 0;
h->list_size = 0;
index 011b3d3d9b6527a9f2c99b635fc9a94630675395..d867c848fa51d26097c752316e5d803bac479a1e 100644 (file)
ignorelist_item_t *entry;
int status;
- re = malloc (sizeof (*re));
+ re = calloc (1, sizeof (*re));
if (re == NULL)
{
- ERROR ("ignorelist_append_regex: malloc failed.");
+ ERROR ("ignorelist_append_regex: calloc failed.");
return (ENOMEM);
}
- memset (re, 0, sizeof (*re));
status = regcomp (re, re_str, REG_EXTENDED);
if (status != 0)
return (status);
}
- entry = malloc (sizeof (*entry));
+ entry = calloc (1, sizeof (*entry));
if (entry == NULL)
{
- ERROR ("ignorelist_append_regex: malloc failed.");
+ ERROR ("ignorelist_append_regex: calloc failed.");
regfree (re);
sfree (re);
return (ENOMEM);
}
- memset (entry, 0, sizeof (*entry));
entry->rmatch = re;
ignorelist_append (il, entry);
ignorelist_item_t *new;
/* create new entry */
- if ((new = malloc(sizeof (*new))) == NULL )
+ if ((new = calloc(1, sizeof (*new))) == NULL )
{
ERROR ("cannot allocate new entry");
return (1);
}
- memset (new, '\0', sizeof(ignorelist_item_t));
new->smatch = sstrdup(entry);
/* append new entry */
{
ignorelist_t *il;
- il = malloc (sizeof (*il));
+ il = calloc (1, sizeof (*il));
if (il == NULL)
return NULL;
- memset (il, 0, sizeof (*il));
/*
* ->ignore == 0 => collect
index 40dd0eaad7563114c63936a922d3a74da8df2b1d..1a6188f612344fedb41157f035b7159af5528df0 100644 (file)
--- a/src/daemon/utils_llist.c
+++ b/src/daemon/utils_llist.c
{
llist_t *ret;
- ret = malloc (sizeof (*ret));
+ ret = calloc (1, sizeof (*ret));
if (ret == NULL)
return (NULL);
- memset (ret, '\0', sizeof (llist_t));
-
return (ret);
}
index c1d99e15aa4f81e413ec7bc852cef630f463a721..cf87b6b7782b7bc5aa461163d6adeed4f1285f9e 100644 (file)
--- a/src/daemon/utils_match.c
+++ b/src/daemon/utils_match.c
@@ -238,10 +238,9 @@ cu_match_t *match_create_callback (const char *regex, const char *excluderegex,
DEBUG ("utils_match: match_create_callback: regex = %s, excluderegex = %s",
regex, excluderegex);
- obj = malloc (sizeof (*obj));
+ obj = calloc (1, sizeof (*obj));
if (obj == NULL)
return (NULL);
- memset (obj, '\0', sizeof (cu_match_t));
status = regcomp (&obj->regex, regex, REG_EXTENDED | REG_NEWLINE);
if (status != 0)
cu_match_value_t *user_data;
cu_match_t *obj;
- user_data = malloc (sizeof (*user_data));
+ user_data = calloc (1, sizeof (*user_data));
if (user_data == NULL)
return (NULL);
- memset (user_data, '\0', sizeof (cu_match_value_t));
user_data->ds_type = match_ds_type;
obj = match_create_callback (regex, excluderegex,
index c4b73c35dffc4c85dc218a2e3baecb1c25178d7f..0b0a8fb41ce9a1064d3d4b27cc9f37c34000e82a 100644 (file)
--- a/src/daemon/utils_tail.c
+++ b/src/daemon/utils_tail.c
{
cu_tail_t *obj;
- obj = malloc (sizeof (*obj));
+ obj = calloc (1, sizeof (*obj));
if (obj == NULL)
return (NULL);
- memset (obj, '\0', sizeof (cu_tail_t));
obj->file = strdup (file);
if (obj->file == NULL)
index c8fd05ef7672e0c991c5e1ad04357f98730be63a..1e5da95e181550b3b54e21df6773be0805e5482d 100644 (file)
{
cu_tail_match_t *obj;
- obj = malloc (sizeof (*obj));
+ obj = calloc (1, sizeof (*obj));
if (obj == NULL)
return (NULL);
- memset (obj, '\0', sizeof (cu_tail_match_t));
obj->tail = cu_tail_create (filename);
if (obj->tail == NULL)
if (match == NULL)
return (-1);
- user_data = malloc (sizeof (*user_data));
+ user_data = calloc (1, sizeof (*user_data));
if (user_data == NULL)
{
match_destroy (match);
return (-1);
}
- memset (user_data, '\0', sizeof (cu_tail_match_simple_t));
sstrncpy (user_data->plugin, plugin, sizeof (user_data->plugin));
if (plugin_instance != NULL)