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.23 by schorsch, Sun Mar 6 01:13:18 2016 UTC vs.
Revision 2.24 by greg, Sat Apr 16 00:42:16 2016 UTC

# Line 138 | Line 138 | load_file(MEMLOAD *mp, FILE *fp)
138   static RECINDEX *
139   index_records(const MEMLOAD *mp, int nw_rec)
140   {
141 +        int             nall = 0;
142          RECINDEX        *rp;
143          char            *cp, *mend;
144          int             n;
# Line 146 | Line 147 | index_records(const MEMLOAD *mp, int nw_rec)
147                  return(NULL);
148          if (nw_rec <= 0)
149                  return(NULL);
150 <        rp = (RECINDEX *)malloc(sizeof(RECINDEX) + mp->len/(2*nw_rec)*sizeof(char *));
150 >        nall = 1000;
151 >        rp = (RECINDEX *)malloc(sizeof(RECINDEX) + nall*sizeof(char *));
152          if (rp == NULL)
153                  return(NULL);
154          rp->nw_rec = nw_rec;
# Line 158 | Line 160 | index_records(const MEMLOAD *mp, int nw_rec)
160                          ++cp;
161                  if (cp >= mend)
162                          break;
163 +                if (rp->nrecs >= nall) {
164 +                        nall += nall>>1;        /* get more record space */
165 +                        rp = (RECINDEX *)realloc(rp,
166 +                                        sizeof(RECINDEX) + nall*sizeof(char *));
167 +                        if (rp == NULL)
168 +                                return(NULL);
169 +                }
170                  rp->rec[rp->nrecs++] = cp;      /* point to first non-white */
171                  n = rp->nw_rec;
172                  while (++cp < mend)             /* find end of record */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines