projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
sfree: don't check for NULL before calling free
[collectd.git]
/
src
/
utils_rrdcreate.c
diff --git
a/src/utils_rrdcreate.c
b/src/utils_rrdcreate.c
index
44c2386
..
2012b84
100644
(file)
--- a/
src/utils_rrdcreate.c
+++ b/
src/utils_rrdcreate.c
@@
-113,13
+113,12
@@
static srrd_create_args_t *srrd_create_args_create (const char *filename,
{
srrd_create_args_t *args;
{
srrd_create_args_t *args;
- args =
malloc (
sizeof (*args));
+ args =
calloc (1,
sizeof (*args));
if (args == NULL)
{
if (args == NULL)
{
- ERROR ("srrd_create_args_create:
m
alloc failed.");
+ ERROR ("srrd_create_args_create:
c
alloc failed.");
return (NULL);
}
return (NULL);
}
- memset (args, 0, sizeof (*args));
args->filename = NULL;
args->pdp_step = pdp_step;
args->last_up = last_up;
args->filename = NULL;
args->pdp_step = pdp_step;
args->last_up = last_up;
@@
-216,9
+215,8
@@
static int rra_get (char ***ret, const value_list_t *vl, /* {{{ */
rra_max = rts_num * rra_types_num;
assert (rra_max > 0);
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);
return (-1);
- memset (rra_def, 0, (rra_max + 1) * sizeof (*rra_def));
rra_num = 0;
cdp_len = 0;
rra_num = 0;
cdp_len = 0;
@@
-292,15
+290,14
@@
static int ds_get (char ***ret, /* {{{ */
assert (ds->ds_num > 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];
if (ds_def == NULL)
{
char errbuf[1024];
- ERROR ("rrdtool plugin:
m
alloc failed: %s",
+ ERROR ("rrdtool plugin:
c
alloc failed: %s",
sstrerror (errno, errbuf, sizeof (errbuf)));
return (-1);
}
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++)
{
for (ds_num = 0; ds_num < ds->ds_num; ds_num++)
{
@@
-358,7
+355,7
@@
static int ds_get (char ***ret, /* {{{ */
return (-1);
}
return (-1);
}
- if (ds_num
<
= 0)
+ if (ds_num
=
= 0)
{
sfree (ds_def);
return (0);
{
sfree (ds_def);
return (0);