if ((rrdnew.stat_head = (stat_head_t*)calloc(1, sizeof(stat_head_t))) == NULL) {
rrd_set_error("allocating stat_head for new RRD");
rrd_free(&rrdold);
rrd_close(rrd_file);
return (-1);
}
if ((rrdnew.stat_head = (stat_head_t*)calloc(1, sizeof(stat_head_t))) == NULL) {
rrd_set_error("allocating stat_head for new RRD");
rrd_free(&rrdold);
rrd_close(rrd_file);
return (-1);
}
if ((rrdnew.rra_def = (rra_def_t *)malloc(sizeof(rra_def_t) * rrdold.stat_head->rra_cnt)) == NULL) {
rrd_set_error("allocating rra_def for new RRD");
rrd_free(&rrdnew);
rrd_free(&rrdold);
rrd_close(rrd_file);
if ((rrdnew.rra_def = (rra_def_t *)malloc(sizeof(rra_def_t) * rrdold.stat_head->rra_cnt)) == NULL) {
rrd_set_error("allocating rra_def for new RRD");
rrd_free(&rrdnew);
rrd_free(&rrdold);
rrd_close(rrd_file);
memcpy(rrdnew.rra_def,rrdold.rra_def,sizeof(rra_def_t) * rrdold.stat_head->rra_cnt);
/* Set this so that the file will be created with the correct size */
memcpy(rrdnew.rra_def,rrdold.rra_def,sizeof(rra_def_t) * rrdold.stat_head->rra_cnt);
/* Set this so that the file will be created with the correct size */
buffer = DNAN;
l = rrdnew.stat_head->ds_cnt * modify;
while (l > 0) {
rrd_write(rrd_out_file, &buffer, sizeof(rrd_value_t) * 1);
l--;
}
buffer = DNAN;
l = rrdnew.stat_head->ds_cnt * modify;
while (l > 0) {
rrd_write(rrd_out_file, &buffer, sizeof(rrd_value_t) * 1);
l--;
}
} else {
/* Removing rows. Normally this would be just after the cursor
** however this may also mean that we wrap to the beginning of
} else {
/* Removing rows. Normally this would be just after the cursor
** however this may also mean that we wrap to the beginning of