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

Comparing ray/src/util/glareval.c (file contents):
Revision 1.9 by greg, Wed Apr 3 15:43:12 1991 UTC vs.
Revision 1.11 by greg, Fri Apr 5 14:57:28 1991 UTC

# Line 20 | Line 20 | static char SCCSid[] = "$SunId$ LBL";
20   #define vfork           fork
21   #endif
22  
23 < #define MAXSBUF         1023980 /* maximum total size of scanline buffer */
23 > #define MAXSBUF         524268  /* maximum total size of scanline buffer */
24   #define HSIZE           317     /* size of scanline hash table */
25   #define NRETIRE         16      /* number of scanlines to retire at once */
26  
# Line 75 | Line 75 | int    y;
75                          if (sl->y == y) {               /* reclaim */
76                                  sl->next = hashtab[hi];
77                                  hashtab[hi] = sl;
78 + #ifdef DEBUG
79 +                                if (verbose)
80 +                                        fprintf(stderr,
81 +                                                "%s: scanline %d reclaimed\n",
82 +                                                        progname, y);
83 + #endif
84                          }
85                          return(sl);
86                  }
# Line 410 | Line 416 | SCAN *
416   scanretire()                    /* retire old scanlines to free list */
417   {
418          SCAN    *sold[NRETIRE];
413        SCAN    head;
419          int     n;
420          int     h;
421          register SCAN   *sl;
422          register int    i;
423                                          /* grab the NRETIRE oldest scanlines */
424          sold[n = 0] = NULL;
425 <        for (h = 0; h < HSIZE; h++) {
426 <                head.next = hashtab[h];
427 <                sl = &head;
428 <                while (sl->next != NULL) {
424 <                        for (i = n; i && sold[i-1]->lused > sl->next->lused; i--)
425 <                                if (i == NRETIRE) {     /* reallocate */
426 <                                        register int    oh;
427 <                                        oh = shash(sold[NRETIRE-1]->y);
428 <                                        sold[NRETIRE-1]->next = hashtab[oh];
429 <                                        if (h == oh) {
430 <                                                head.next = sold[NRETIRE-1];
431 <                                                if (sl == &head)
432 <                                                        sl = head.next;
433 <                                        } else
434 <                                                hashtab[oh] = sold[NRETIRE-1];
435 <                                } else                  /* else bubble up */
425 >        for (h = 0; h < HSIZE; h++)
426 >                for (sl = hashtab[h]; sl != NULL; sl = sl->next) {
427 >                        for (i = n; i && sold[i-1]->lused > sl->lused; i--)
428 >                                if (i < NRETIRE)
429                                          sold[i] = sold[i-1];
430                          if (i < NRETIRE) {
431 <                                sold[i] = sl->next;
439 <                                sl->next = sl->next->next;
431 >                                sold[i] = sl;
432                                  if (n < NRETIRE)        /* grow list */
433                                          n++;
434 <                        } else
443 <                                sl = sl->next;
434 >                        }
435                  }
445                hashtab[h] = head.next;
446        }
436                                          /* put scanlines into free list */
437 <        for (i = 1; i < n; i++) {
438 <                sold[i]->next = freelist;
439 <                freelist = sold[i];
437 >        for (i = 0; i < n; i++) {
438 >                h = shash(sold[i]->y);
439 >                sl = hashtab[h];
440 >                if (sl == sold[i])
441 >                        hashtab[h] = sl->next;
442 >                else {
443 >                        while (sl->next != sold[i])     /* IS in list */
444 >                                sl = sl->next;
445 >                        sl->next = sold[i]->next;
446 >                }
447 >                if (i > 0) {            /* save oldest as return value */
448 >                        sold[i]->next = freelist;
449 >                        freelist = sold[i];
450 >                }
451          }
452          return(sold[0]);
453   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines