From: oetiker Date: Sat, 24 Feb 2007 17:23:02 +0000 (+0000) Subject: fix memmory problem in rrd_dump.c X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9becc239839e47acb1ca494365931cfb750f927c;p=rrdtool.git fix memmory problem in rrd_dump.c git-svn-id: svn://svn.oetiker.ch/rrdtool/branches/1.2/program@1010 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/src/rrd_dump.c b/src/rrd_dump.c index 4edd7c0..4e79c9c 100644 --- a/src/rrd_dump.c +++ b/src/rrd_dump.c @@ -115,39 +115,39 @@ rrd_dump_r(const char *filename, char *outname) fprintf(out_file, "\t %ld \n\n", rrd.live_head->last_up,somestring); for(i=0;ids_cnt;i++){ - fprintf(out_file, "\t\n"); - fprintf(out_file, "\t\t %s \n",rrd.ds_def[i].ds_nam); - fprintf(out_file, "\t\t %s \n",rrd.ds_def[i].dst); - if (dst_conv(rrd.ds_def[i].dst) != DST_CDEF) { - fprintf(out_file, "\t\t %lu \n",rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt); - if (isnan(rrd.ds_def[i].par[DS_min_val].u_val)){ - fprintf(out_file, "\t\t NaN \n"); - } else { - fprintf(out_file, "\t\t %0.10e \n",rrd.ds_def[i].par[DS_min_val].u_val); - } - if (isnan(rrd.ds_def[i].par[DS_max_val].u_val)){ - fprintf(out_file, "\t\t NaN \n"); - } else { - fprintf(out_file, "\t\t %0.10e \n",rrd.ds_def[i].par[DS_max_val].u_val); - } - } else { /* DST_CDEF */ - char *str; - rpn_compact2str((rpn_cdefds_t *) &(rrd.ds_def[i].par[DS_cdef]),rrd.ds_def,&str); - fprintf(out_file, "\t\t %s \n", str); - free(str); - } - fprintf(out_file, "\n\t\t\n"); - fprintf(out_file, "\t\t %s \n",rrd.pdp_prep[i].last_ds); - if (isnan(rrd.pdp_prep[i].scratch[PDP_val].u_val)){ - fprintf(out_file, "\t\t NaN \n"); - } else { - fprintf(out_file, "\t\t %0.10e \n",rrd.pdp_prep[i].scratch[PDP_val].u_val); - } - fprintf(out_file, "\t\t %lu \n", - rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt); + fprintf(out_file, "\t\n"); + fprintf(out_file, "\t\t %s \n",rrd.ds_def[i].ds_nam); + fprintf(out_file, "\t\t %s \n",rrd.ds_def[i].dst); + if (dst_conv(rrd.ds_def[i].dst) != DST_CDEF) { + fprintf(out_file, "\t\t %lu \n",rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt); + if (isnan(rrd.ds_def[i].par[DS_min_val].u_val)){ + fprintf(out_file, "\t\t NaN \n"); + } else { + fprintf(out_file, "\t\t %0.10e \n",rrd.ds_def[i].par[DS_min_val].u_val); + } + if (isnan(rrd.ds_def[i].par[DS_max_val].u_val)){ + fprintf(out_file, "\t\t NaN \n"); + } else { + fprintf(out_file, "\t\t %0.10e \n",rrd.ds_def[i].par[DS_max_val].u_val); + } + } else { /* DST_CDEF */ + char *str=NULL; + rpn_compact2str((rpn_cdefds_t *) &(rrd.ds_def[i].par[DS_cdef]),rrd.ds_def,&str); + fprintf(out_file, "\t\t %s \n", str); + free(str); + } + fprintf(out_file, "\n\t\t\n"); + fprintf(out_file, "\t\t %s \n",rrd.pdp_prep[i].last_ds); + if (isnan(rrd.pdp_prep[i].scratch[PDP_val].u_val)){ + fprintf(out_file, "\t\t NaN \n"); + } else { + fprintf(out_file, "\t\t %0.10e \n",rrd.pdp_prep[i].scratch[PDP_val].u_val); + } + fprintf(out_file, "\t\t %lu \n", + rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt); - fprintf(out_file, "\t\n\n"); - } + fprintf(out_file, "\t\n\n"); + } fputs("", out_file); diff --git a/src/rrd_info.c b/src/rrd_info.c index 1ff1659..91f4959 100644 --- a/src/rrd_info.c +++ b/src/rrd_info.c @@ -117,7 +117,7 @@ rrd_info_r(char *filename) { switch (current_ds) { case DST_CDEF: { - char *buffer = 0; + char *buffer = NULL; rpn_compact2str((rpn_cdefds_t *) &(rrd.ds_def[i].par[DS_cdef]), rrd.ds_def, &buffer); info.u_str = buffer; diff --git a/src/rrd_tune.c b/src/rrd_tune.c index ecdedf2..5651ad0 100644 --- a/src/rrd_tune.c +++ b/src/rrd_tune.c @@ -290,7 +290,7 @@ rrd_tune(int argc, char **argv) rrd.ds_def[i].par[DS_min_val].u_val, rrd.ds_def[i].par[DS_max_val].u_val); } else { - char *buffer; + char *buffer = NULL; rpn_compact2str((rpn_cdefds_t *) &(rrd.ds_def[i].par[DS_cdef]),rrd.ds_def,&buffer); printf("DS[%s] typ: %s\tcdef: %s\n", rrd.ds_def[i].ds_nam,rrd.ds_def[i].dst,buffer); free(buffer);