treewide: cleanup malloc calls
[collectd.git] / src / processes.c
index aca2369..d2c0f44 100644 (file)
@@ -262,7 +262,7 @@ static void ps_list_register (const char *name, const char *regexp)
        procstat_t *ptr;
        int status;
 
-       new = (procstat_t *) malloc (sizeof (procstat_t));
+       new = malloc (sizeof (*new));
        if (new == NULL)
        {
                ERROR ("processes plugin: ps_list_register: malloc failed.");
@@ -275,7 +275,7 @@ static void ps_list_register (const char *name, const char *regexp)
        if (regexp != NULL)
        {
                DEBUG ("ProcessMatch: adding \"%s\" as criteria to process %s.", regexp, name);
-               new->re = (regex_t *) malloc (sizeof (regex_t));
+               new->re = malloc (sizeof (*new->re));
                if (new->re == NULL)
                {
                        ERROR ("processes plugin: ps_list_register: malloc failed.");
@@ -410,7 +410,7 @@ static void ps_list_add (const char *name, const char *cmdline, procstat_entry_t
                {
                        procstat_entry_t *new;
 
-                       new = (procstat_entry_t *) malloc (sizeof (procstat_entry_t));
+                       new = malloc (sizeof (*new));
                        if (new == NULL)
                                return;
                        memset (new, 0, sizeof (procstat_entry_t));
@@ -1001,7 +1001,7 @@ static procstat_t *ps_read_io (long pid, procstat_t *ps)
        return (ps);
 } /* procstat_t *ps_read_io */
 
-int ps_read_process (long pid, procstat_t *ps, char *state)
+static int ps_read_process (long pid, procstat_t *ps, char *state)
 {
        char  filename[64];
        char  buffer[1024];
@@ -1255,7 +1255,7 @@ static char *ps_get_cmdline (long pid, char *name, char *buf, size_t buf_len)
        return buf;
 } /* char *ps_get_cmdline (...) */
 
-static int read_fork_rate ()
+static int read_fork_rate (void)
 {
        FILE *proc_stat;
        char buffer[1024];
@@ -1450,7 +1450,7 @@ static int ps_read_process(long pid, procstat_t *ps, char *state)
  * are retrieved from kstat (module cpu, name sys, class misc, stat nthreads).
  * The result is the sum for all the threads created on each cpu
  */
-static int read_fork_rate()
+static int read_fork_rate (void)
 {
        extern kstat_ctl_t *kc;
        kstat_t *ksp_chain = NULL;