return (-1);
}
- if (modify < 0)
+ if (modify < 0) {
if ((long) rrdold.rra_def[target_rra].row_cnt <= -modify) {
rrd_set_error("This RRA is not that big");
rrd_free(&rrdold);
rrd_close(rrd_file);
return (-1);
}
-
+ } else {
+ /* the size of the new file */
+ rrdnew.stat_head = rrd_file->file_len +
+ (rrdold.stat_head->ds_cnt * sizeof(rrd_value_t) * modify);
+ }
rrd_out_file = rrd_open(outfilename, &rrdnew, RRD_READWRITE | RRD_CREAT);
if (rrd_out_file == NULL) {
rrd_set_error("Can't create '%s': %s", outfilename,
rrd_write(rrd_out_file, &buffer, sizeof(rrd_value_t) * 1);
l--;
}
+#ifndef HAVE_MMAP
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
+ /* for the mmap case, we did already fill the whole new file with DNAN
+ * before we copied the old values, so nothing to do here. */
+#endif
} else {
/* Removing rows. Normally this would be just after the cursor
** however this may also mean that we wrap to the beginning of