#include <locale.h>
+// prototype
+static int write_rrd(const char *outfilename, rrd_t *out);
+
/* a convenience realloc/memcpy combo */
static void * copy_over_realloc(void *dest, int dest_index,
const void *src, int index,
char *old_locale = NULL;
char *ops = NULL;
unsigned int ops_cnt = 0;
- char *tmpfile = NULL;
old_locale = setlocale(LC_NUMERIC, NULL);
setlocale(LC_NUMERIC, "C");
out_rra++;
}
+ rc = write_rrd(outfilename, &out);
+
+done:
+ /* clean up */
+ if (old_locale)
+ setlocale(LC_NUMERIC, old_locale);
+
+ if (rrd_file != NULL) {
+ rrd_close(rrd_file);
+ }
+ rrd_free(&in);
+ rrd_free(&out);
+
+ if (ops != NULL) free(ops);
+
+ return rc;
+}
+
+
+static int write_rrd(const char *outfilename, rrd_t *out) {
+ int rc = -1;
+ char *tmpfile = NULL;
+
/* write out the new file */
FILE *fh = NULL;
if (strcmp(outfilename, "-") == 0) {
}
}
- rc = write_fh(fh, &out);
+ rc = write_fh(fh, out);
if (fh != NULL && tmpfile != NULL) {
/* tmpfile != NULL indicates that we did NOT write to stdout,
unlink(tmpfile);
}
}
-
done:
- /* clean up */
- if (old_locale)
- setlocale(LC_NUMERIC, old_locale);
-
if (tmpfile != NULL)
free(tmpfile);
-
- if (rrd_file != NULL) {
- rrd_close(rrd_file);
- }
- rrd_free(&in);
- rrd_free(&out);
-
- if (ops != NULL) free(ops);
return rc;
}