19 |
|
#ifdef SMLMEM |
20 |
|
#define OSTSIZ 32749 /* object table size (a prime!) */ |
21 |
|
#else |
22 |
< |
#define OSTSIZ 262139 /* object table size (a prime!) */ |
22 |
> |
#define OSTSIZ 1002583 /* object table size (a prime!) */ |
23 |
|
#endif |
24 |
|
#endif |
25 |
|
|
26 |
+ |
#undef xtra_long |
27 |
+ |
#ifdef _WIN64 |
28 |
+ |
typedef unsigned long long int xtra_long; |
29 |
+ |
#else |
30 |
+ |
typedef unsigned long int xtra_long; |
31 |
+ |
#endif |
32 |
+ |
|
33 |
|
static OBJECT *ostable[OSTSIZ]; /* the object set table */ |
34 |
|
|
35 |
|
|
36 |
|
void |
37 |
< |
insertelem(os, obj) /* insert obj into os, no questions */ |
38 |
< |
register OBJECT *os; |
39 |
< |
OBJECT obj; |
37 |
> |
insertelem( /* insert obj into os, no questions */ |
38 |
> |
OBJECT *os, |
39 |
> |
OBJECT obj |
40 |
> |
) |
41 |
|
{ |
42 |
< |
register int i; |
42 |
> |
int i; |
43 |
|
|
44 |
|
for (i = os[0]++; i > 0; i--) |
45 |
|
if (os[i] > obj) |
51 |
|
|
52 |
|
|
53 |
|
void |
54 |
< |
deletelem(os, obj) /* delete obj from os, no questions */ |
55 |
< |
register OBJECT *os; |
56 |
< |
OBJECT obj; |
54 |
> |
deletelem( /* delete obj from os, no questions */ |
55 |
> |
OBJECT *os, |
56 |
> |
OBJECT obj |
57 |
> |
) |
58 |
|
{ |
59 |
< |
register int i; |
59 |
> |
int i; |
60 |
|
|
61 |
|
i = (*os)--; |
62 |
|
os++; |
72 |
|
|
73 |
|
|
74 |
|
int |
75 |
< |
inset(os, obj) /* determine if object is in set */ |
76 |
< |
register OBJECT *os; |
77 |
< |
OBJECT obj; |
75 |
> |
inset( /* determine if object is in set */ |
76 |
> |
OBJECT *os, |
77 |
> |
OBJECT obj |
78 |
> |
) |
79 |
|
{ |
80 |
|
int upper, lower; |
81 |
< |
register int cm, i; |
81 |
> |
int cm, i; |
82 |
|
|
83 |
< |
if ((i = os[0]) <= 6) { /* linear search algorithm */ |
83 |
> |
if ((i = os[0]) <= 12) { /* linear search algorithm */ |
84 |
|
cm = obj; |
85 |
|
while (i-- > 0) |
86 |
|
if (*++os == cm) |
105 |
|
|
106 |
|
|
107 |
|
int |
108 |
< |
setequal(os1, os2) /* determine if two sets are equal */ |
109 |
< |
register OBJECT *os1, *os2; |
108 |
> |
setequal( /* determine if two sets are equal */ |
109 |
> |
OBJECT *os1, |
110 |
> |
OBJECT *os2 |
111 |
> |
) |
112 |
|
{ |
113 |
< |
register int i; |
113 |
> |
int i; |
114 |
|
|
115 |
|
for (i = *os1; i-- >= 0; ) |
116 |
|
if (*os1++ != *os2++) |
120 |
|
|
121 |
|
|
122 |
|
void |
123 |
< |
setcopy(os1, os2) /* copy object set os2 into os1 */ |
124 |
< |
register OBJECT *os1, *os2; |
123 |
> |
setcopy( /* copy object set os2 into os1 */ |
124 |
> |
OBJECT *os1, |
125 |
> |
OBJECT *os2 |
126 |
> |
) |
127 |
|
{ |
128 |
< |
register int i; |
128 |
> |
int i; |
129 |
|
|
130 |
|
for (i = *os2; i-- >= 0; ) |
131 |
|
*os1++ = *os2++; |
133 |
|
|
134 |
|
|
135 |
|
OBJECT * |
136 |
< |
setsave(os) /* allocate space and save set */ |
137 |
< |
register OBJECT *os; |
136 |
> |
setsave( /* allocate space and save set */ |
137 |
> |
OBJECT *os |
138 |
> |
) |
139 |
|
{ |
140 |
|
OBJECT *osnew; |
141 |
< |
register OBJECT *oset; |
142 |
< |
register int i; |
141 |
> |
OBJECT *oset; |
142 |
> |
int i; |
143 |
|
|
144 |
|
if ((osnew = oset = (OBJECT *)malloc((*os+1)*sizeof(OBJECT))) == NULL) |
145 |
|
error(SYSTEM, "out of memory in setsave\n"); |
150 |
|
|
151 |
|
|
152 |
|
void |
153 |
< |
setunion(osr, os1, os2) /* osr = os1 Union os2 */ |
154 |
< |
register OBJECT *osr, *os1, *os2; |
153 |
> |
setunion( /* osr = os1 Union os2 */ |
154 |
> |
OBJECT *osr, |
155 |
> |
OBJECT *os1, |
156 |
> |
OBJECT *os2 |
157 |
> |
) |
158 |
|
{ |
159 |
< |
register int i1, i2; |
159 |
> |
int i1, i2; |
160 |
|
|
161 |
|
osr[0] = 0; |
162 |
|
for (i1 = i2 = 1; i1 <= os1[0] || i2 <= os2[0]; ) { |
173 |
|
|
174 |
|
|
175 |
|
void |
176 |
< |
setintersect(osr, os1, os2) /* osr = os1 Intersect os2 */ |
177 |
< |
register OBJECT *osr, *os1, *os2; |
176 |
> |
setintersect( /* osr = os1 Intersect os2 */ |
177 |
> |
OBJECT *osr, |
178 |
> |
OBJECT *os1, |
179 |
> |
OBJECT *os2 |
180 |
> |
) |
181 |
|
{ |
182 |
< |
register int i1, i2; |
182 |
> |
int i1, i2; |
183 |
|
|
184 |
|
osr[0] = 0; |
185 |
|
if (os1[0] <= 0) |
198 |
|
|
199 |
|
|
200 |
|
OCTREE |
201 |
< |
fullnode(oset) /* return octree for object set */ |
202 |
< |
OBJECT *oset; |
201 |
> |
fullnode( /* return octree for object set */ |
202 |
> |
OBJECT *oset |
203 |
> |
) |
204 |
|
{ |
205 |
< |
int osentry, ntries; |
206 |
< |
long hval; |
205 |
> |
unsigned int ntries; |
206 |
> |
xtra_long hval; |
207 |
|
OCTREE ot; |
208 |
< |
register int i; |
209 |
< |
register OBJECT *os; |
208 |
> |
int osentry, i; |
209 |
> |
OBJECT *os; |
210 |
|
/* hash on set */ |
211 |
|
hval = 0; |
212 |
|
os = oset; |
215 |
|
hval += *os++; |
216 |
|
ntries = 0; |
217 |
|
tryagain: |
218 |
< |
osentry = (hval + (long)ntries*ntries) % OSTSIZ; |
218 |
> |
osentry = (hval + (xtra_long)ntries*ntries) % OSTSIZ; |
219 |
|
os = ostable[osentry]; |
220 |
|
if (os == NULL) { |
221 |
|
os = ostable[osentry] = (OBJECT *)malloc( |
252 |
|
return(ot); |
253 |
|
memerr: |
254 |
|
error(SYSTEM, "out of memory in fullnode"); |
255 |
< |
return NULL; /* pro forma return */ |
255 |
> |
return 0; /* pro forma return */ |
256 |
|
} |
257 |
|
|
258 |
|
|
259 |
|
void |
260 |
< |
objset(oset, ot) /* get object set for full node */ |
261 |
< |
register OBJECT *oset; |
262 |
< |
OCTREE ot; |
260 |
> |
objset( /* get object set for full node */ |
261 |
> |
OBJECT *oset, |
262 |
> |
OCTREE ot |
263 |
> |
) |
264 |
|
{ |
265 |
< |
register OBJECT *os; |
266 |
< |
register int i; |
265 |
> |
OBJECT *os; |
266 |
> |
int i; |
267 |
|
|
268 |
|
if (!isfull(ot)) |
269 |
|
goto noderr; |
281 |
|
} |
282 |
|
|
283 |
|
|
261 |
– |
int |
262 |
– |
dosets(f) /* loop through all sets */ |
263 |
– |
int (*f)(); |
264 |
– |
{ |
265 |
– |
int res = 0; |
266 |
– |
int n; |
267 |
– |
register OBJECT *os; |
268 |
– |
|
269 |
– |
for (n = 0; n < OSTSIZ; n++) { |
270 |
– |
if ((os = ostable[n]) == NULL) |
271 |
– |
continue; |
272 |
– |
while (*os > 0) { |
273 |
– |
res += (*f)(os); |
274 |
– |
os += *os + 1; |
275 |
– |
} |
276 |
– |
} |
277 |
– |
return(res); |
278 |
– |
} |
279 |
– |
|
280 |
– |
|
284 |
|
void |
285 |
< |
donesets() /* free ALL SETS in our table */ |
285 |
> |
donesets(void) /* free ALL SETS in our table */ |
286 |
|
{ |
287 |
< |
register int n; |
287 |
> |
int n; |
288 |
|
|
289 |
|
for (n = 0; n < OSTSIZ; n++) |
290 |
|
if (ostable[n] != NULL) { |