projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
collectctl: define LOCALSTATEDIR if not defined
[collectd.git]
/
src
/
utils_rrdcreate.c
diff --git
a/src/utils_rrdcreate.c
b/src/utils_rrdcreate.c
index
44c2386
..
884de8f
100644
(file)
--- a/
src/utils_rrdcreate.c
+++ b/
src/utils_rrdcreate.c
@@
-25,6
+25,7
@@
**/
#include "collectd.h"
**/
#include "collectd.h"
+
#include "common.h"
#include "utils_rrdcreate.h"
#include "common.h"
#include "utils_rrdcreate.h"
@@
-70,7
+71,7
@@
static const char *const rra_types[] =
};
static int rra_types_num = STATIC_ARRAY_SIZE (rra_types);
};
static int rra_types_num = STATIC_ARRAY_SIZE (rra_types);
-#if !defined(HAVE_THREADSAFE_LIBRRD)
|| !HAVE_THREADSAFE_LIBRRD
+#if !defined(HAVE_THREADSAFE_LIBRRD)
static pthread_mutex_t librrd_lock = PTHREAD_MUTEX_INITIALIZER;
#endif
static pthread_mutex_t librrd_lock = PTHREAD_MUTEX_INITIALIZER;
#endif
@@
-82,9
+83,7
@@
static pthread_mutex_t async_creation_lock = PTHREAD_MUTEX_INITIALIZER;
*/
static void rra_free (int rra_num, char **rra_def) /* {{{ */
{
*/
static void rra_free (int rra_num, char **rra_def) /* {{{ */
{
- int i;
-
- for (i = 0; i < rra_num; i++)
+ for (int i = 0; i < rra_num; i++)
{
sfree (rra_def[i]);
}
{
sfree (rra_def[i]);
}
@@
-99,8
+98,7
@@
static void srrd_create_args_destroy (srrd_create_args_t *args)
sfree (args->filename);
if (args->argv != NULL)
{
sfree (args->filename);
if (args->argv != NULL)
{
- int i;
- for (i = 0; i < args->argc; i++)
+ for (int i = 0; i < args->argc; i++)
sfree (args->argv[i]);
sfree (args->argv);
}
sfree (args->argv[i]);
sfree (args->argv);
}
@@
-113,13
+111,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;
@@
-173,7
+170,6
@@
static int rra_get (char ***ret, const value_list_t *vl, /* {{{ */
int cdp_num;
int cdp_len;
int cdp_num;
int cdp_len;
- int i, j;
/* The stepsize we use here: If it is user-set, use it. If not, use the
* interval of the value-list. */
/* The stepsize we use here: If it is user-set, use it. If not, use the
* interval of the value-list. */
@@
-216,13
+212,12
@@
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;
- for (i = 0; i < rts_num; i++)
+ for (i
nt i
= 0; i < rts_num; i++)
{
int span = rts[i];
{
int span = rts[i];
@@
-238,7
+233,7
@@
static int rra_get (char ***ret, const value_list_t *vl, /* {{{ */
cdp_num = (int) ceil (((double) span)
/ ((double) (cdp_len * ss)));
cdp_num = (int) ceil (((double) span)
/ ((double) (cdp_len * ss)));
- for (j = 0; j < rra_types_num; j++)
+ for (
int
j = 0; j < rra_types_num; j++)
{
char buffer[128];
int status;
{
char buffer[128];
int status;
@@
-271,9
+266,7
@@
static int rra_get (char ***ret, const value_list_t *vl, /* {{{ */
static void ds_free (int ds_num, char **ds_def) /* {{{ */
{
static void ds_free (int ds_num, char **ds_def) /* {{{ */
{
- int i;
-
- for (i = 0; i < ds_num; i++)
+ for (int i = 0; i < ds_num; i++)
if (ds_def[i] != NULL)
free (ds_def[i]);
free (ds_def);
if (ds_def[i] != NULL)
free (ds_def[i]);
free (ds_def);
@@
-292,15
+285,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
+350,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);