test for tm.tm_gmtoff presence in configure.ac fix for #330
[rrdtool.git] / src / rrd_format.c
index 501b267..fba9eb0 100644 (file)
@@ -48,6 +48,9 @@
  *
  *****************************************************************************/
 #include "rrd_tool.h"
+#ifdef WIN32
+#include "stdlib.h"
+#endif
 
 #define converter(VV,VVV) \
    if (strcmp(#VV, string) == 0) return VVV;
@@ -125,8 +128,7 @@ off_t rrd_get_header_size(
     return sizeof(stat_head_t) + \
         sizeof(ds_def_t) * rrd->stat_head->ds_cnt + \
         sizeof(rra_def_t) * rrd->stat_head->rra_cnt + \
-        sizeof(time_t) + \
-        sizeof(live_head_t) + \
+        ( atoi(rrd->stat_head->version) < 3 ? sizeof(time_t) : sizeof(live_head_t) ) + \
         sizeof(pdp_prep_t) * rrd->stat_head->ds_cnt + \
         sizeof(cdp_prep_t) * rrd->stat_head->ds_cnt * rrd->stat_head->rra_cnt + \
         sizeof(rra_ptr_t) * rrd->stat_head->rra_cnt;