ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/rcollate.c
(Generate patch)

Comparing ray/src/util/rcollate.c (file contents):
Revision 2.27 by greg, Thu Oct 18 22:59:48 2018 UTC vs.
Revision 2.28 by greg, Fri Oct 19 16:53:37 2018 UTC

# Line 90 | Line 90 | static int
90   load_file(MEMLOAD *mp, FILE *fp)
91   {
92          int     fd;
93 <        off_t   skip, flen, skipped;
93 >        off_t   skip, flen, fpos;
94  
95   #if defined(_WIN32) || defined(_WIN64)
96                                  /* too difficult to fix this */
# Line 117 | Line 117 | load_file(MEMLOAD *mp, FILE *fp)
117                          mp->mapped = 1;
118                          return(1);      /* mmap() success */
119                  }
120 <                mp->base = NULL;        /* fall back to reading it in... */
120 >                mp->base = NULL;        /* else fall back to reading it in... */
121          }
122   #endif
123          if (lseek(fd, skip, SEEK_SET) != skip ||
# Line 125 | Line 125 | load_file(MEMLOAD *mp, FILE *fp)
125                  mp->len = 0;
126                  return(-1);
127          }
128 <        skipped = skip;                 /* read() fails on really big buffers */
129 <        while (skipped < flen) {
130 <                ssize_t nread = read(fd, (char *)mp->base+(skipped-skip),
131 <                                (flen-skipped <= 1L<<30) ? flen-skipped : 1L<<30);
128 >        fpos = skip;
129 >        while (fpos < flen) {           /* read() fails if n > 2 GBytes */
130 >                ssize_t nread = read(fd, (char *)mp->base+(fpos-skip),
131 >                                (flen-fpos < 1L<<24) ? flen-fpos : 1L<<24);
132                  if (nread <= 0) {
133                          free_load(mp);
134                          return(-1);
135                  }
136 <                skipped += nread;
136 >                fpos += nread;
137          }
138          return(1);
139   }
# Line 370 | Line 370 | do_transpose(const MEMLOAD *mp)
370                          putc(tabEOL[j >= no_columns-1], stdout);
371                  } else {                        /* binary output */
372                          putbinary((char *)mp->base +
373 <                            (unsigned long)(n_comp*comp_size)*(j*ni_columns + i),
373 >                                (size_t)(n_comp*comp_size)*(j*ni_columns + i),
374                                          comp_size, n_comp, stdout);
375                  }
376              if (ferror(stdout)) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines