projects
/
rrdtool.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
win32 portability patch and win32/rrdlib.vcproj file for the source
[rrdtool.git]
/
src
/
rrd_create.c
diff --git
a/src/rrd_create.c
b/src/rrd_create.c
index
c48900f
..
f5dbd58
100644
(file)
--- a/
src/rrd_create.c
+++ b/
src/rrd_create.c
@@
-14,6
+14,10
@@
#include "rrd_is_thread_safe.h"
#include "rrd_is_thread_safe.h"
+#ifdef WIN32
+# include <process.h>
+#endif
+
unsigned long FnvHash(
const char *str);
int create_hw_contingent_rras(
unsigned long FnvHash(
const char *str);
int create_hw_contingent_rras(
@@
-24,8
+28,6
@@
void parseGENERIC_DS(
const char *def,
rrd_t *rrd,
int ds_idx);
const char *def,
rrd_t *rrd,
int ds_idx);
-long int rra_random_row(
- rra_def_t *);
static void rrd_free2(
rrd_t *rrd); /* our onwn copy, immmune to mmap */
static void rrd_free2(
rrd_t *rrd); /* our onwn copy, immmune to mmap */
@@
-126,14
+128,14
@@
int rrd_create_r(
/* init rrd clean */
rrd_init(&rrd);
/* static header */
/* init rrd clean */
rrd_init(&rrd);
/* static header */
- if ((rrd.stat_head = calloc(1, sizeof(stat_head_t))) == NULL) {
+ if ((rrd.stat_head =
(stat_head_t*)
calloc(1, sizeof(stat_head_t))) == NULL) {
rrd_set_error("allocating rrd.stat_head");
rrd_free2(&rrd);
return (-1);
}
/* live header */
rrd_set_error("allocating rrd.stat_head");
rrd_free2(&rrd);
return (-1);
}
/* live header */
- if ((rrd.live_head = calloc(1, sizeof(live_head_t))) == NULL) {
+ if ((rrd.live_head =
(live_head_t*)
calloc(1, sizeof(live_head_t))) == NULL) {
rrd_set_error("allocating rrd.live_head");
rrd_free2(&rrd);
return (-1);
rrd_set_error("allocating rrd.live_head");
rrd_free2(&rrd);
return (-1);
@@
-164,7
+166,7
@@
int rrd_create_r(
if (strncmp(argv[i], "DS:", 3) == 0) {
size_t old_size = sizeof(ds_def_t) * (rrd.stat_head->ds_cnt);
if (strncmp(argv[i], "DS:", 3) == 0) {
size_t old_size = sizeof(ds_def_t) * (rrd.stat_head->ds_cnt);
- if ((rrd.ds_def = rrd_realloc(rrd.ds_def,
+ if ((rrd.ds_def =
(ds_def_t*)
rrd_realloc(rrd.ds_def,
old_size + sizeof(ds_def_t))) ==
NULL) {
rrd_set_error("allocating rrd.ds_def");
old_size + sizeof(ds_def_t))) ==
NULL) {
rrd_set_error("allocating rrd.ds_def");
@@
-233,7
+235,7
@@
int rrd_create_r(
size_t old_size = sizeof(rra_def_t) * (rrd.stat_head->rra_cnt);
int row_cnt;
size_t old_size = sizeof(rra_def_t) * (rrd.stat_head->rra_cnt);
int row_cnt;
- if ((rrd.rra_def = rrd_realloc(rrd.rra_def,
+ if ((rrd.rra_def =
(rra_def_t*)
rrd_realloc(rrd.rra_def,
old_size + sizeof(rra_def_t))) ==
NULL) {
rrd_set_error("allocating rrd.rra_def");
old_size + sizeof(rra_def_t))) ==
NULL) {
rrd_set_error("allocating rrd.rra_def");
@@
-608,7
+610,7
@@
int create_hw_contingent_rras(
(rrd->stat_head->rra_cnt)++;
/* allocate the memory for the 4 contingent RRAs */
old_size = sizeof(rra_def_t) * (rrd->stat_head->rra_cnt);
(rrd->stat_head->rra_cnt)++;
/* allocate the memory for the 4 contingent RRAs */
old_size = sizeof(rra_def_t) * (rrd->stat_head->rra_cnt);
- if ((rrd->rra_def = rrd_realloc(rrd->rra_def,
+ if ((rrd->rra_def =
(rra_def_t*)
rrd_realloc(rrd->rra_def,
old_size + 4 * sizeof(rra_def_t))) ==
NULL) {
rrd_free2(rrd);
old_size + 4 * sizeof(rra_def_t))) ==
NULL) {
rrd_free2(rrd);
@@
-696,7
+698,7
@@
int rrd_create_fn(
rrd_write(rrd_file_dn, rrd->live_head, sizeof(live_head_t));
rrd_write(rrd_file_dn, rrd->live_head, sizeof(live_head_t));
- if ((rrd->pdp_prep = calloc(1, sizeof(pdp_prep_t))) == NULL) {
+ if ((rrd->pdp_prep =
(pdp_prep_t*)
calloc(1, sizeof(pdp_prep_t))) == NULL) {
rrd_set_error("allocating pdp_prep");
rrd_free2(rrd);
rrd_close(rrd_file_dn);
rrd_set_error("allocating pdp_prep");
rrd_free2(rrd);
rrd_close(rrd_file_dn);
@@
-712,7
+714,7
@@
int rrd_create_fn(
for (i = 0; i < rrd->stat_head->ds_cnt; i++)
rrd_write(rrd_file_dn, rrd->pdp_prep, sizeof(pdp_prep_t));
for (i = 0; i < rrd->stat_head->ds_cnt; i++)
rrd_write(rrd_file_dn, rrd->pdp_prep, sizeof(pdp_prep_t));
- if ((rrd->cdp_prep = calloc(1, sizeof(cdp_prep_t))) == NULL) {
+ if ((rrd->cdp_prep =
(cdp_prep_t*)
calloc(1, sizeof(cdp_prep_t))) == NULL) {
rrd_set_error("allocating cdp_prep");
rrd_free2(rrd);
rrd_close(rrd_file_dn);
rrd_set_error("allocating cdp_prep");
rrd_free2(rrd);
rrd_close(rrd_file_dn);
@@
-759,7
+761,7
@@
int rrd_create_fn(
/* now, we must make sure that the rest of the rrd
struct is properly initialized */
/* now, we must make sure that the rest of the rrd
struct is properly initialized */
- if ((rrd->rra_ptr = calloc(1, sizeof(rra_ptr_t))) == NULL) {
+ if ((rrd->rra_ptr =
(rra_ptr_t*)
calloc(1, sizeof(rra_ptr_t))) == NULL) {
rrd_set_error("allocating rra_ptr");
rrd_free2(rrd);
rrd_close(rrd_file_dn);
rrd_set_error("allocating rra_ptr");
rrd_free2(rrd);
rrd_close(rrd_file_dn);
@@
-771,7
+773,7
@@
int rrd_create_fn(
* would occur for cur_row = 1 because rrd_update increments
* the pointer a priori. */
for (i = 0; i < rrd->stat_head->rra_cnt; i++) {
* would occur for cur_row = 1 because rrd_update increments
* the pointer a priori. */
for (i = 0; i < rrd->stat_head->rra_cnt; i++) {
- rrd->rra_ptr->cur_row = rr
a_random_row(
&rrd->rra_def[i]);
+ rrd->rra_ptr->cur_row = rr
d_select_initial_row(rrd_file_dn, i,
&rrd->rra_def[i]);
rrd_write(rrd_file_dn, rrd->rra_ptr, sizeof(rra_ptr_t));
}
rrd_write(rrd_file_dn, rrd->rra_ptr, sizeof(rra_ptr_t));
}
@@
-825,15
+827,3
@@
static void rrd_free2(
free(rrd->rrd_value);
}
free(rrd->rrd_value);
}
-static int rand_init = 0;
-
-long int rra_random_row(
- rra_def_t *rra)
-{
- if (!rand_init) {
- srandom((unsigned int) time(NULL) + (unsigned int) getpid());
- rand_init++;
- }
-
- return random() % rra->row_cnt;
-}