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

Comparing ray/src/common/readobj.c (file contents):
Revision 2.22 by greg, Sat Apr 8 03:56:44 2017 UTC vs.
Revision 2.25 by greg, Tue Feb 7 20:28:16 2023 UTC

# Line 47 | Line 47 | readobj(                               /* read in an object file or stream */
47                  sprintf(errmsg, "cannot open scene file \"%s\"", inpspec);
48                  error(SYSTEM, errmsg);
49          }
50 + #ifdef getc_unlocked                    /* avoid stupid semaphores */
51 +        flockfile(infp);
52 + #endif
53          while ((c = getc(infp)) != EOF) {
54                  if (isspace(c))
55                          continue;
# Line 63 | Line 66 | readobj(                               /* read in an object file or stream */
66          }
67          if (inpspec[0] == '!')
68                  pclose(infp);
69 <        else
69 >        else if (infp != stdin)
70                  fclose(infp);
71 + #ifdef getc_unlocked
72 +        else
73 +                funlockfile(infp);
74 + #endif
75          if (nobjects == lastobj) {
76                  sprintf(errmsg, "(%s): empty file", inpspec);
77                  error(WARNING, errmsg);
# Line 198 | Line 205 | freeobjects(                           /* free a range of objects */
205                  freefargs(&o->oargs);
206                  memset((void *)o, '\0', sizeof(OBJREC));
207          }
201        clearobjndx();
208                                          /* free objects off end */
209          for (obj = nobjects; obj-- > 0; )
210                  if (objptr(obj)->oname != NULL)
211                          break;
212 <        ++obj;
212 >        if (++obj >= nobjects)
213 >                return;
214          while (nobjects > obj)          /* free empty end blocks */
215                  if ((--nobjects & (OBJBLKSIZ-1)) == 0) {
216                          int     i = nobjects >> OBJBLKSHFT;
217                          free((void *)objblock[i]);
218                          objblock[i] = NULL;
219                  }
220 +        truncobjndx();                  /* truncate modifier look-up */
221   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines