projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
daemon: malloc + memset -> calloc
[collectd.git]
/
src
/
daemon
/
configfile.c
diff --git
a/src/daemon/configfile.c
b/src/daemon/configfile.c
index
8a7621d
..
78d4eea
100644
(file)
--- a/
src/daemon/configfile.c
+++ b/
src/daemon/configfile.c
@@
-717,14
+717,13
@@
static oconfig_item_t *cf_read_dir (const char *dir,
return (NULL);
}
return (NULL);
}
- root =
(oconfig_item_t *) malloc (sizeof (oconfig_item_
t));
+ root =
calloc (1, sizeof (*roo
t));
if (root == NULL)
{
if (root == NULL)
{
- ERROR ("configfile:
m
alloc failed.");
+ ERROR ("configfile:
c
alloc failed.");
closedir (dh);
return (NULL);
}
closedir (dh);
return (NULL);
}
- memset (root, 0, sizeof (oconfig_item_t));
while ((de = readdir (dh)) != NULL)
{
while ((de = readdir (dh)) != NULL)
{
@@
-835,13
+834,12
@@
static oconfig_item_t *cf_read_generic (const char *path,
return (NULL);
}
return (NULL);
}
- root =
(oconfig_item_t *) malloc (sizeof (oconfig_item_
t));
+ root =
calloc (1, sizeof (*roo
t));
if (root == NULL)
{
if (root == NULL)
{
- ERROR ("configfile:
m
alloc failed.");
+ ERROR ("configfile:
c
alloc failed.");
return (NULL);
}
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. */
/* wordexp() might return a sorted list already. That's not
* documented though, so let's make sure we get what we want. */
@@
-1067,7
+1065,7
@@
void cf_register (const char *type,
cf_unregister (type);
/* This pointer will be free'd in `cf_unregister' */
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;
return;
cf_cb->type = type;
@@
-1084,7
+1082,7
@@
int cf_register_complex (const char *type, int (*callback) (oconfig_item_t *))
{
cf_complex_callback_t *new;
{
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);
if (new == NULL)
return (-1);