From 9a973a00bf26f89da8d4c3b6ecf8460d1459ccb0 Mon Sep 17 00:00:00 2001
From: Uwe Schulzweida <uwe.schulzweida@mpimet.mpg.de>
Date: Wed, 2 Jan 2019 14:56:47 +0100
Subject: [PATCH] timecache_t: changed type of variable from int to size_t.

---
 src/basetime.h     | 6 +++---
 src/stream_cdf_i.c | 9 +++++----
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/basetime.h b/src/basetime.h
index 57dfba3f9..2835e178b 100644
--- a/src/basetime.h
+++ b/src/basetime.h
@@ -7,9 +7,9 @@
 #define MAX_TIMECACHE_SIZE 1024
 
 typedef struct {
-  int size;
-  int startid;
-  int maxvals;
+  size_t size;
+  size_t startid;
+  size_t maxvals;
   double cache[MAX_TIMECACHE_SIZE];
 }
 timecache_t;
diff --git a/src/stream_cdf_i.c b/src/stream_cdf_i.c
index 8036e7c47..9a061fe1b 100644
--- a/src/stream_cdf_i.c
+++ b/src/stream_cdf_i.c
@@ -4128,13 +4128,14 @@ double get_timevalue(int fileID, int nctimevarid, int tsID, timecache_t *tcache)
     {
       if ( tcache->size == 0 || (tsID < tcache->startid || tsID > (tcache->startid+tcache->size-1)) )
         {
-          int maxvals = MAX_TIMECACHE_SIZE;
+          size_t maxvals = MAX_TIMECACHE_SIZE;
           tcache->startid = (tsID/MAX_TIMECACHE_SIZE)*MAX_TIMECACHE_SIZE;
           if ( (tcache->startid + maxvals) > tcache->maxvals ) maxvals = (tcache->maxvals)%MAX_TIMECACHE_SIZE;
           tcache->size = maxvals;
-          size_t index = (size_t) tcache->startid;
-          // fprintf(stderr, "fill time cache: %d %d %d %d %d\n", tcache->maxvals, tsID, tcache->startid, tcache->startid+maxvals-1, maxvals);
-          for ( int ival = 0; ival < maxvals; ++ival )
+          //fprintf(stderr, "fill time cache: %d %d %d %d %d\n", tcache->maxvals, tsID, tcache->startid, tcache->startid+maxvals-1, maxvals);
+          //cdf_get_vara_double(fileID, nctimevarid, &tcache->startid, &maxvals, tcache->cache);
+          size_t index = tcache->startid;
+          for ( size_t ival = 0; ival < maxvals; ++ival )
             {
               cdf_get_var1_double(fileID, nctimevarid, &index, &timevalue);
               tcache->cache[ival] = timevalue;
-- 
GitLab