projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
hugepages: rework
[collectd.git]
/
src
/
rrdtool.c
diff --git
a/src/rrdtool.c
b/src/rrdtool.c
index
4a3c345
..
21b01d9
100644
(file)
--- a/
src/rrdtool.c
+++ b/
src/rrdtool.c
@@
-32,10
+32,6
@@
#include <rrd.h>
#include <rrd.h>
-#if HAVE_PTHREAD_H
-# include <pthread.h>
-#endif
-
/*
* Private types
*/
/*
* Private types
*/
@@
-166,7
+162,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.");
@@
-442,7
+438,7
@@
static void *rrd_queue_thread (void __attribute__((unused)) *data)
}
/* Update `tv_next_update' */
}
/* Update `tv_next_update' */
- if (write_rate > 0.0)
+ if (write_rate > 0.0)
{
gettimeofday (&tv_now, /* timezone = */ NULL);
tv_next_update.tv_sec = tv_now.tv_sec;
{
gettimeofday (&tv_now, /* timezone = */ NULL);
tv_next_update.tv_sec = tv_now.tv_sec;
@@
-480,7
+476,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);
@@
-522,7
+518,7
@@
static int rrd_queue_dequeue (const char *filename,
{
if (strcmp (this->filename, filename) == 0)
break;
{
if (strcmp (this->filename, filename) == 0)
break;
-
+
prev = this;
this = this->next;
}
prev = this;
this = this->next;
}
@@
-588,7
+584,7
@@
static void rrd_cache_flush (cdtime_t timeout)
}
else /* ancient and no values -> waste of memory */
{
}
else /* ancient and no values -> waste of memory */
{
- char **tmp =
(char **) realloc ((void *)
keys,
+ char **tmp =
realloc (
keys,
(keys_num + 1) * sizeof (char *));
if (tmp == NULL)
{
(keys_num + 1) * sizeof (char *));
if (tmp == NULL)
{
@@
-607,7
+603,7
@@
static void rrd_cache_flush (cdtime_t timeout)
}
} /* while (c_avl_iterator_next) */
c_avl_iterator_destroy (iter);
}
} /* while (c_avl_iterator_next) */
c_avl_iterator_destroy (iter);
-
+
for (i = 0; i < keys_num; i++)
{
if (c_avl_remove (cache, keys[i], (void *) &key, (void *) &rc) != 0)
for (i = 0; i < keys_num; i++)
{
if (c_avl_remove (cache, keys[i], (void *) &key, (void *) &rc) != 0)
@@
-756,7
+752,7
@@
static int rrd_cache_insert (const char *filename,
return (-1);
}
return (-1);
}
- values_new =
(char **)
realloc ((void *) rc->values,
+ values_new = realloc ((void *) rc->values,
(rc->values_num + 1) * sizeof (char *));
if (values_new == NULL)
{
(rc->values_num + 1) * sizeof (char *));
if (values_new == NULL)
{
@@
-1018,11
+1014,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
+1028,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)
@@
-1083,7
+1083,7
@@
static int rrd_config (const char *key, const char *value)
while ((ptr = strtok_r (dummy, ", \t", &saveptr)) != NULL)
{
dummy = NULL;
while ((ptr = strtok_r (dummy, ", \t", &saveptr)) != NULL)
{
dummy = NULL;
-
+
tmp_alloc = realloc (rrdcreate_config.timespans,
sizeof (int) * (rrdcreate_config.timespans_num + 1));
if (tmp_alloc == NULL)
tmp_alloc = realloc (rrdcreate_config.timespans,
sizeof (int) * (rrdcreate_config.timespans_num + 1));
if (tmp_alloc == NULL)