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

Comparing ray/src/common/octree.c (file contents):
Revision 1.1 by greg, Thu Feb 2 10:34:37 1989 UTC vs.
Revision 2.3 by gwlarson, Mon Aug 24 15:30:11 1998 UTC

# Line 15 | Line 15 | static char SCCSid[] = "$SunId$ LBL";
15   #include  "octree.h"
16  
17   OCTREE  *octblock[MAXOBLK];             /* our octree */
18 < static OCTREE  ofreelist = EMPTY;       /* free octree nodes */
18 > static OCTREE  ofreelist = EMPTY;       /* freed octree nodes */
19   static OCTREE  treetop = 0;             /* next free node */
20  
21  
# Line 33 | Line 33 | octalloc()                     /* allocate an octree */
33                  errno = 0;
34                  if (octbi(freet) >= MAXOBLK)
35                          return(EMPTY);
36 <                if ((octblock[octbi(freet)] = (OCTREE *)malloc(
36 >                if ((octblock[octbi(freet)] = (OCTREE *)bmalloc(
37                                  (unsigned)256*8*sizeof(OCTREE))) == NULL)
38                          return(EMPTY);
39          }
# Line 56 | Line 56 | register OCTREE  ot;
56   }
57  
58  
59 + octdone()                       /* free EVERYTHING */
60 + {
61 +        register int    i;
62 +
63 +        for (i = 0; i < MAXOBLK; i++) {
64 +                if (octblock[i] == NULL)
65 +                        break;
66 +                bfree((char *)octblock[i], (unsigned)256*8*sizeof(OCTREE));
67 +                octblock[i] = NULL;
68 +        }
69 +        ofreelist = EMPTY;
70 +        treetop = 0;
71 + }
72 +
73 +
74   OCTREE
75   combine(ot)                     /* recursively combine nodes */
76   register OCTREE  ot;
# Line 69 | Line 84 | register OCTREE  ot;
84          for (i = 1; i < 8; i++)
85                  if ((octkid(ot, i) = combine(octkid(ot, i))) != ores)
86                          ores = ot;
87 <        if (!istree(ores))      /* all were identical leaves */
88 <                octfree(ot);
87 >        if (!istree(ores)) {    /* all were identical leaves */
88 >                octkid(ot, 0) = ofreelist;
89 >                ofreelist = ot;
90 >        }
91          return(ores);
92   }
93  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines