summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b66183e)
raw | patch | inline | side by side (parent: b66183e)
author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 1 Apr 2016 16:31:11 +0000 (18:31 +0200) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Fri, 1 Apr 2016 16:32:42 +0000 (18:32 +0200) |
diff --git a/src/utils_db_query.c b/src/utils_db_query.c
index de435cb4e64afd40f2574b94ec06292d7bbe9aae..74c3a81fe7c69d8052f1ce54baae71e70a6547ac 100644 (file)
--- a/src/utils_db_query.c
+++ b/src/utils_db_query.c
ci->values_num, (ci->values_num == 1) ? "" : "s");
}
- r = malloc (sizeof (*r));
+ r = calloc (1, sizeof (*r));
if (r == NULL)
{
- ERROR ("db query utils: malloc failed.");
+ ERROR ("db query utils: calloc failed.");
return (-1);
}
- memset (r, 0, sizeof (*r));
r->type = NULL;
r->instance_prefix = NULL;
r->instances = NULL;
return (-1);
}
- q = malloc (sizeof (*q));
+ q = calloc (1, sizeof (*q));
if (q == NULL)
{
- ERROR ("db query utils: malloc failed.");
+ ERROR ("db query utils: calloc failed.");
return (-1);
}
- memset (q, 0, sizeof (*q));
q->min_version = 0;
q->max_version = UINT_MAX;
udb_result_preparation_area_t **next_r_area;
udb_result_t *r;
- q_area = malloc (sizeof (*q_area));
+ q_area = calloc (1, sizeof (*q_area));
if (q_area == NULL)
return NULL;
- memset (q_area, 0, sizeof (*q_area));
next_r_area = &q_area->result_prep_areas;
for (r = q->results; r != NULL; r = r->next)
{
udb_result_preparation_area_t *r_area;
- r_area = malloc (sizeof (*r_area));
+ r_area = calloc (1, sizeof (*r_area));
if (r_area == NULL)
{
udb_result_preparation_area_t *a = q_area->result_prep_areas;
return NULL;
}
- memset (r_area, 0, sizeof (*r_area));
-
*next_r_area = r_area;
next_r_area = &r_area->next;
}
diff --git a/src/utils_fbhash.c b/src/utils_fbhash.c
index cbd150610205255a8a20478a324175a7feebd35a..f27c08272cb5cde3734975236164943bcd2757bd 100644 (file)
--- a/src/utils_fbhash.c
+++ b/src/utils_fbhash.c
if (file == NULL)
return (NULL);
- h = malloc (sizeof (*h));
+ h = calloc (1, sizeof (*h));
if (h == NULL)
return (NULL);
- memset (h, 0, sizeof (*h));
h->filename = strdup (file);
if (h->filename == NULL)
diff --git a/src/utils_latency.c b/src/utils_latency.c
index ca7d5fab3d582672554f344fb9ed60791fdbb1f1..41af00cb14188b5e51f8a9d0e3d3e559e16a2967 100644 (file)
--- a/src/utils_latency.c
+++ b/src/utils_latency.c
{
latency_counter_t *lc;
- lc = malloc (sizeof (*lc));
+ lc = calloc (1, sizeof (*lc));
if (lc == NULL)
return (NULL);
- memset (lc, 0, sizeof (*lc));
latency_counter_reset (lc);
lc->bin_width = HISTOGRAM_DEFAULT_BIN_WIDTH;
diff --git a/src/utils_mount.c b/src/utils_mount.c
index ecf011d80d751e4f1c565fb2337136bf651cbd45..a36882c475ac2143395d628c7afdb31b3c249782 100644 (file)
--- a/src/utils_mount.c
+++ b/src/utils_mount.c
return (NULL);
}
- if ((buf = malloc (bufsize * sizeof (*buf))) == NULL)
+ if ((buf = calloc (bufsize, sizeof (*buf))) == NULL)
return (NULL);
- memset (buf, '\0', bufsize * sizeof (STRUCT_STATFS));
/* The bufsize needs to be passed in bytes. Really. This is not in the
* manpage.. -octo */
for (i = 0; i < num; i++)
{
- if ((new = malloc (sizeof (*new))) == NULL)
+ if ((new = calloc (1, sizeof (*new))) == NULL)
break;
- memset (new, '\0', sizeof (cu_mount_t));
-
+
/* Copy values from `struct mnttab' */
new->dir = sstrdup (buf[i].f_mntonname);
new->spec_device = sstrdup (buf[i].f_mntfromname);
while (getmntent (fp, &mt) == 0)
{
- if ((new = malloc (sizeof (*new))) == NULL)
+ if ((new = calloc (1, sizeof (*new))) == NULL)
break;
- memset (new, '\0', sizeof (cu_mount_t));
-
+
/* Copy values from `struct mnttab' */
new->dir = sstrdup (mt.mnt_mountp);
new->spec_device = sstrdup (mt.mnt_special);
while (getmntent_r (fp, &me, mntbuf, sizeof (mntbuf) ))
{
- if ((new = malloc (sizeof (*new))) == NULL)
+ if ((new = calloc (1, sizeof (*new))) == NULL)
break;
- memset (new, '\0', sizeof (cu_mount_t));
/* Copy values from `struct mntent *' */
new->dir = sstrdup (me.mnt_dir);
while ((me = getmntent (fp)) != NULL)
{
- if ((new = malloc (sizeof (*new))) == NULL)
+ if ((new = calloc (1, sizeof (*new))) == NULL)
break;
- memset (new, '\0', sizeof (cu_mount_t));
-
+
/* Copy values from `struct mntent *' */
new->dir = sstrdup (me->mnt_dir);
new->spec_device = sstrdup (me->mnt_fsname);
diff --git a/src/utils_rrdcreate.c b/src/utils_rrdcreate.c
index 44c2386f16ad74775a9bcabaaa09d497658343b3..fb04201cedd4f3b886eeb67447585886346db8bf 100644 (file)
--- a/src/utils_rrdcreate.c
+++ b/src/utils_rrdcreate.c
{
srrd_create_args_t *args;
- args = malloc (sizeof (*args));
+ args = calloc (1, sizeof (*args));
if (args == NULL)
{
- ERROR ("srrd_create_args_create: malloc failed.");
+ ERROR ("srrd_create_args_create: calloc failed.");
return (NULL);
}
- memset (args, 0, sizeof (*args));
args->filename = NULL;
args->pdp_step = pdp_step;
args->last_up = last_up;
rra_max = rts_num * rra_types_num;
assert (rra_max > 0);
- if ((rra_def = malloc ((rra_max + 1) * sizeof (*rra_def))) == NULL)
+ if ((rra_def = calloc (rra_max + 1, sizeof (*rra_def))) == NULL)
return (-1);
- memset (rra_def, 0, (rra_max + 1) * sizeof (*rra_def));
rra_num = 0;
cdp_len = 0;
assert (ds->ds_num > 0);
- ds_def = malloc (ds->ds_num * sizeof (*ds_def));
+ ds_def = calloc (ds->ds_num, sizeof (*ds_def));
if (ds_def == NULL)
{
char errbuf[1024];
- ERROR ("rrdtool plugin: malloc failed: %s",
+ ERROR ("rrdtool plugin: calloc failed: %s",
sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
- memset (ds_def, 0, ds->ds_num * sizeof (*ds_def));
for (ds_num = 0; ds_num < ds->ds_num; ds_num++)
{
diff --git a/src/utils_vl_lookup.c b/src/utils_vl_lookup.c
index f85910e1737e7b5d1c328a6e9e15896be2d60d99..d3eeab3c06fa9b784993d9b3a983d3bcf215ed83 100644 (file)
--- a/src/utils_vl_lookup.c
+++ b/src/utils_vl_lookup.c
{
user_obj_t *user_obj;
- user_obj = malloc (sizeof (*user_obj));
+ user_obj = calloc (1, sizeof (*user_obj));
if (user_obj == NULL)
{
- ERROR ("utils_vl_lookup: malloc failed.");
+ ERROR ("utils_vl_lookup: calloc failed.");
return (NULL);
}
- memset (user_obj, 0, sizeof (*user_obj));
user_obj->next = NULL;
user_obj->user_obj = obj->cb_user_class (ds, vl, user_class->user_class);
return (NULL);
}
- by_type = malloc (sizeof (*by_type));
+ by_type = calloc (1, sizeof (*by_type));
if (by_type == NULL)
{
- ERROR ("utils_vl_lookup: malloc failed.");
+ ERROR ("utils_vl_lookup: calloc failed.");
sfree (type_copy);
return (NULL);
}
- memset (by_type, 0, sizeof (*by_type));
by_type->wildcard_plugin_list = NULL;
-
+
by_type->by_plugin_tree = c_avl_create ((void *) strcmp);
if (by_type->by_plugin_tree == NULL)
{
lookup_free_class_callback_t cb_free_class,
lookup_free_obj_callback_t cb_free_obj)
{
- lookup_t *obj = malloc (sizeof (*obj));
+ lookup_t *obj = calloc (1, sizeof (*obj));
if (obj == NULL)
{
- ERROR ("utils_vl_lookup: malloc failed.");
+ ERROR ("utils_vl_lookup: calloc failed.");
return (NULL);
}
- memset (obj, 0, sizeof (*obj));
obj->by_type_tree = c_avl_create ((void *) strcmp);
if (obj->by_type_tree == NULL)
if (by_type == NULL)
return (-1);
- user_class_obj = malloc (sizeof (*user_class_obj));
+ user_class_obj = calloc (1, sizeof (*user_class_obj));
if (user_class_obj == NULL)
{
- ERROR ("utils_vl_lookup: malloc failed.");
+ ERROR ("utils_vl_lookup: calloc failed.");
return (ENOMEM);
}
- memset (user_class_obj, 0, sizeof (*user_class_obj));
pthread_mutex_init (&user_class_obj->entry.lock, /* attr = */ NULL);
user_class_obj->entry.user_class = user_class;
lu_copy_ident_to_match (&user_class_obj->entry.match, ident, group_by);