projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into f/riemann/rcc
[collectd.git]
/
src
/
processes.c
diff --git
a/src/processes.c
b/src/processes.c
index
d2c0f44
..
efc64d0
100644
(file)
--- a/
src/processes.c
+++ b/
src/processes.c
@@
-262,13
+262,12
@@
static void ps_list_register (const char *name, const char *regexp)
procstat_t *ptr;
int status;
procstat_t *ptr;
int status;
- new =
malloc (
sizeof (*new));
+ new =
calloc (1,
sizeof (*new));
if (new == NULL)
{
if (new == NULL)
{
- ERROR ("processes plugin: ps_list_register:
m
alloc failed.");
+ ERROR ("processes plugin: ps_list_register:
c
alloc failed.");
return;
}
return;
}
- memset (new, 0, sizeof (procstat_t));
sstrncpy (new->name, name, sizeof (new->name));
#if HAVE_REGEX_H
sstrncpy (new->name, name, sizeof (new->name));
#if HAVE_REGEX_H
@@
-410,10
+409,9
@@
static void ps_list_add (const char *name, const char *cmdline, procstat_entry_t
{
procstat_entry_t *new;
{
procstat_entry_t *new;
- new =
malloc (
sizeof (*new));
+ new =
calloc (1,
sizeof (*new));
if (new == NULL)
return;
if (new == NULL)
return;
- memset (new, 0, sizeof (procstat_entry_t));
new->id = entry->id;
if (pse == NULL)
new->id = entry->id;
if (pse == NULL)
@@
-1348,18
+1346,15
@@
static int ps_read_process(long pid, procstat_t *ps, char *state)
snprintf(f_usage, sizeof (f_usage), "/proc/%li/usage", pid);
snprintf(f_usage, sizeof (f_usage), "/proc/%li/usage", pid);
- buffer = malloc(sizeof (pstatus_t));
- memset(buffer, 0, sizeof (pstatus_t));
+ buffer = calloc(1, sizeof (pstatus_t));
read_file_contents(filename, buffer, sizeof (pstatus_t));
myStatus = (pstatus_t *) buffer;
read_file_contents(filename, buffer, sizeof (pstatus_t));
myStatus = (pstatus_t *) buffer;
- buffer = malloc(sizeof (psinfo_t));
- memset(buffer, 0, sizeof(psinfo_t));
+ buffer = calloc(1, sizeof (psinfo_t));
read_file_contents(f_psinfo, buffer, sizeof (psinfo_t));
myInfo = (psinfo_t *) buffer;
read_file_contents(f_psinfo, buffer, sizeof (psinfo_t));
myInfo = (psinfo_t *) buffer;
- buffer = malloc(sizeof (prusage_t));
- memset(buffer, 0, sizeof(prusage_t));
+ buffer = calloc(1, sizeof (prusage_t));
read_file_contents(f_usage, buffer, sizeof (prusage_t));
myUsage = (prusage_t *) buffer;
read_file_contents(f_usage, buffer, sizeof (prusage_t));
myUsage = (prusage_t *) buffer;
@@
-1369,6
+1364,10
@@
static int ps_read_process(long pid, procstat_t *ps, char *state)
ps->num_proc = 0;
ps->num_lwp = 0;
*state = (char) 'Z';
ps->num_proc = 0;
ps->num_lwp = 0;
*state = (char) 'Z';
+
+ sfree(myStatus);
+ sfree(myInfo);
+ sfree(myUsage);
return (0);
} else {
ps->num_proc = 1;
return (0);
} else {
ps->num_proc = 1;