From: oetiker Date: Wed, 22 Feb 2012 10:27:42 +0000 (+0000) Subject: kill a few warnings and properly release memory -- martin sperl X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=cbcac9088b48078f872b2840a43f69a9277d0e12;p=rrdtool-all.git kill a few warnings and properly release memory -- martin sperl git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@2275 a5681a0c-68f1-0310-ab6d-d61299d08faa --- diff --git a/program/src/rrd_xport.c b/program/src/rrd_xport.c index 4a7b688b..a0dd9e77 100644 --- a/program/src/rrd_xport.c +++ b/program/src/rrd_xport.c @@ -5,6 +5,7 @@ ****************************************************************************/ #include +#include #include "rrd_tool.h" #include "rrd_graph.h" @@ -381,6 +382,9 @@ int rrd_graph_xport(image_desc_t *im) { info.u_cnt = im->step; grinfo_push(im, sprintf_alloc("graph_step"), RD_I_CNT, info); + /* set locale */ + char *old_locale = setlocale(LC_NUMERIC,NULL); + setlocale(LC_NUMERIC, "C"); /* format it for output */ int r=0; @@ -403,9 +407,20 @@ int rrd_graph_xport(image_desc_t *im) { default: break; } + /* restore locale */ + setlocale(LC_NUMERIC, old_locale); /* handle errors */ if (r) { + /* free legend */ + for (unsigned long j = 0; j < col_cnt; j++) { + free(legend_v[j]); + } + free(legend_v); + /* free data */ + free(data); + /* free the bufer */ if (buffer.data) {free(buffer.data);} + /* and return with error */ return r; } @@ -512,7 +527,7 @@ int rrd_xport_format_sv(char sep, stringbuffer_t *buffer,image_desc_t *im,time_t localtime_r(&ti,&loc); strftime(buf,254,timefmt,&loc); } else { - snprintf(buf,254,"%ul",ti); + snprintf(buf,254,"%lld",(long long int)ti); } if (addToBuffer(buffer,buf,0)) { return 1; } /* write the columns */