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

Comparing ray/src/rt/ambient.c (file contents):
Revision 2.13 by greg, Fri Oct 2 16:14:53 1992 UTC vs.
Revision 2.14 by greg, Tue Nov 3 21:29:52 1992 UTC

# Line 400 | Line 400 | ambsync()                      /* flush ambient file */
400  
401   #else
402  
403 #include  <fcntl.h>
403   #include  <sys/types.h>
404   #include  <sys/stat.h>
405  
# Line 410 | Line 409 | ambsync()                      /* synchronize ambient file */
409          static FILE  *ambinp = NULL;
410          struct flock  fls;
411          struct stat  sts;
412 + #define flen    sts.st_size
413          AMBVAL  avs;
414 <        long  lastpos, flen;
414 >        long  lastpos;
415          register int  n;
416                                  /* gain exclusive access */
417          fls.l_type = F_WRLCK;
# Line 424 | Line 424 | ambsync()                      /* synchronize ambient file */
424          lastpos = lseek(fileno(ambfp), 0L, 1);  /* get previous position */
425          if (fstat(fileno(ambfp), &sts) < 0)     /* get current length */
426                  error(SYSTEM, "cannot stat ambient file");
427        flen = sts.st_size;
427          if (n = (flen - lastpos)/AMBVALSIZ) {   /* file has grown */
428 <                if (ambinp == NULL)             /* use duplicate file */
428 >                if (ambinp == NULL) {           /* use duplicate file */
429                          ambinp = fdopen(dup(fileno(ambfp)), "r");
430 +                        if (ambinp == NULL)
431 +                                error(SYSTEM, "fdopen failed in ambsync");
432 +                }
433                  while (n--) {                   /* load contributed values */
434                          readambval(&avs, ambinp);
435                          avinsert(&avs,&atrunk,thescene.cuorg,thescene.cusize);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines