diff --git a/src/basetime.h b/src/basetime.h index 57dfba3f9dcdadd817b71852e677aea2972d339b..2835e178ba161cb63f5a320629699b647287d730 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 8036e7c477509965fc802c6dca5847e7fcfba554..9a061fe1b53d2af3041fe5d3344f291533a31d1f 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;