projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
filecount plugin: malloc + memset -> calloc
[collectd.git]
/
src
/
rrdtool.c
diff --git
a/src/rrdtool.c
b/src/rrdtool.c
index
9b04d10
..
6b44f67
100644
(file)
--- a/
src/rrdtool.c
+++ b/
src/rrdtool.c
@@
-166,7
+166,7
@@
static int srrd_update (char *filename, char *template,
assert (template == NULL);
new_argc = 2 + argc;
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.");
if (new_argv == NULL)
{
ERROR ("rrdtool plugin: malloc failed.");
@@
-204,7
+204,7
@@
static int value_list_to_string_multiple (char *buffer, int buffer_len,
int offset;
int status;
time_t tt;
int offset;
int status;
time_t tt;
-
in
t i;
+
size_
t i;
memset (buffer, '\0', buffer_len);
memset (buffer, '\0', buffer_len);
@@
-480,7
+480,7
@@
static int rrd_queue_enqueue (const char *filename,
{
rrd_queue_t *queue_entry;
{
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);
if (queue_entry == NULL)
return (-1);
@@
-1018,11
+1018,11
@@
static int rrd_config (const char *key, const char *value)
return (1);
}
return (1);
}
- len = strlen (
datadir
);
- while ((len > 0) && (
datadir
[len - 1] == '/'))
+ len = strlen (
tmp
);
+ while ((len > 0) && (
tmp
[len - 1] == '/'))
{
len--;
{
len--;
-
datadir
[len] = 0;
+
tmp
[len] = 0;
}
if (len == 0)
}
if (len == 0)
@@
-1032,7
+1032,11
@@
static int rrd_config (const char *key, const char *value)
return (1);
}
return (1);
}
- sfree (datadir);
+ if (datadir != NULL)
+ {
+ sfree (datadir);
+ }
+
datadir = tmp;
}
else if (strcasecmp ("StepSize", key) == 0)
datadir = tmp;
}
else if (strcasecmp ("StepSize", key) == 0)