--- ray/src/common/octree.c 1989/02/02 10:34:37 1.1 +++ ray/src/common/octree.c 1991/11/12 16:55:14 2.1 @@ -15,7 +15,7 @@ static char SCCSid[] = "$SunId$ LBL"; #include "octree.h" OCTREE *octblock[MAXOBLK]; /* our octree */ -static OCTREE ofreelist = EMPTY; /* free octree nodes */ +static OCTREE ofreelist = EMPTY; /* freed octree nodes */ static OCTREE treetop = 0; /* next free node */ @@ -33,7 +33,7 @@ octalloc() /* allocate an octree */ errno = 0; if (octbi(freet) >= MAXOBLK) return(EMPTY); - if ((octblock[octbi(freet)] = (OCTREE *)malloc( + if ((octblock[octbi(freet)] = (OCTREE *)bmalloc( (unsigned)256*8*sizeof(OCTREE))) == NULL) return(EMPTY); } @@ -69,8 +69,10 @@ register OCTREE ot; for (i = 1; i < 8; i++) if ((octkid(ot, i) = combine(octkid(ot, i))) != ores) ores = ot; - if (!istree(ores)) /* all were identical leaves */ - octfree(ot); + if (!istree(ores)) { /* all were identical leaves */ + octkid(ot, 0) = ofreelist; + ofreelist = ot; + } return(ores); }