-/*XXX: do one write for those parts of header that are unchanged */
- if ((rrdnew.stat_head = malloc(sizeof(stat_head_t))) == NULL) {
- rrd_set_error("allocating stat_head for new RRD");
+ 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 */
+ rrdnew.rra_def[target_rra].row_cnt += 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_strerror(errno));