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.10 by greg, Fri Apr 5 14:41:55 1991 UTC

# Line 410 | Line 410 | SCAN *
410   scanretire()                    /* retire old scanlines to free list */
411   {
412          SCAN    *sold[NRETIRE];
413        SCAN    head;
413          int     n;
414          int     h;
415          register SCAN   *sl;
416          register int    i;
417                                          /* grab the NRETIRE oldest scanlines */
418          sold[n = 0] = NULL;
419 <        for (h = 0; h < HSIZE; h++) {
420 <                head.next = hashtab[h];
421 <                sl = &head;
422 <                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 */
419 >        for (h = 0; h < HSIZE; h++)
420 >                for (sl = hashtab[h]; sl != NULL; sl = sl->next) {
421 >                        for (i = n; i && sold[i-1]->lused > sl->lused; i--)
422 >                                if (i < NRETIRE)
423                                          sold[i] = sold[i-1];
424                          if (i < NRETIRE) {
425 <                                sold[i] = sl->next;
439 <                                sl->next = sl->next->next;
425 >                                sold[i] = sl;
426                                  if (n < NRETIRE)        /* grow list */
427                                          n++;
428 <                        } else
443 <                                sl = sl->next;
428 >                        }
429                  }
445                hashtab[h] = head.next;
446        }
430                                          /* put scanlines into free list */
431 <        for (i = 1; i < n; i++) {
432 <                sold[i]->next = freelist;
433 <                freelist = sold[i];
431 >        for (i = 0; i < n; i++) {
432 >                h = shash(sold[i]->y);
433 >                sl = hashtab[h];
434 >                if (sl == sold[i])
435 >                        hashtab[h] = sl->next;
436 >                else {
437 >                        while (sl->next != sold[i])     /* IS in list */
438 >                                sl = sl->next;
439 >                        sl->next = sold[i]->next;
440 >                }
441 >                if (i > 0) {            /* save oldest as return value */
442 >                        sold[i]->next = freelist;
443 >                        freelist = sold[i];
444 >                }
445          }
446          return(sold[0]);
447   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines