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 |
|
|
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 |
|
} |
69 |
|
for (i = 1; i < 8; i++) |
70 |
|
if ((octkid(ot, i) = combine(octkid(ot, i))) != ores) |
71 |
|
ores = ot; |
72 |
< |
if (!istree(ores)) /* all were identical leaves */ |
73 |
< |
octfree(ot); |
72 |
> |
if (!istree(ores)) { /* all were identical leaves */ |
73 |
> |
octkid(ot, 0) = ofreelist; |
74 |
> |
ofreelist = ot; |
75 |
> |
} |
76 |
|
return(ores); |
77 |
|
} |
78 |
|
|