X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Frrd_create.c;h=a5c304fb13b874c6736272801c1180cc39236c8d;hb=8238f5f6f0b38b8237a6edd081772b03d9f448cb;hp=766b783460e205b7f7132b820b77a6298926209c;hpb=51fcea2cbf9721f012f2f0d43c604a3aaf684ee8;p=rrdtool.git diff --git a/src/rrd_create.c b/src/rrd_create.c index 766b783..a5c304f 100644 --- a/src/rrd_create.c +++ b/src/rrd_create.c @@ -25,6 +25,13 @@ int rrd_create( int argc, char **argv) { + struct option long_options[] = { + {"start", required_argument, 0, 'b'}, + {"step", required_argument, 0, 's'}, + {0, 0, 0, 0} + }; + int option_index = 0; + int opt; time_t last_up = time(NULL) - 10; unsigned long pdp_step = 300; struct rrd_time_value last_up_tv; @@ -36,14 +43,6 @@ int rrd_create( opterr = 0; /* initialize getopt */ while (1) { - static struct option long_options[] = { - {"start", required_argument, 0, 'b'}, - {"step", required_argument, 0, 's'}, - {0, 0, 0, 0} - }; - int option_index = 0; - int opt; - opt = getopt_long(argc, argv, "b:s:", long_options, &option_index); if (opt == EOF) @@ -633,12 +632,7 @@ int rrd_create_fn( if ((rrd_file = fopen(file_name, "wb")) == NULL) { rrd_set_error("creating '%s': %s", file_name, rrd_strerror(errno)); - free(rrd->stat_head); - rrd->stat_head = NULL; - free(rrd->ds_def); - rrd->ds_def = NULL; - free(rrd->rra_def); - rrd->rra_def = NULL; + rrd_free(rrd); return (-1); }