17 |
|
#include "otypes.h" |
18 |
|
|
19 |
|
|
20 |
< |
FUN ofun[NUMOTYPE] = INIT_OTYPE; /* our object function table */ |
20 |
> |
extern int (*addobjnotify[])(); /* people to notify of new objects */ |
21 |
|
|
22 |
|
static struct ohtab { |
23 |
|
int hsiz; /* current table size */ |
66 |
|
insertobject(obj) /* insert new object into our list */ |
67 |
|
register OBJECT obj; |
68 |
|
{ |
69 |
< |
register int ndx; |
69 |
> |
register int i; |
70 |
|
|
71 |
|
#ifdef GETOBJ |
72 |
< |
ndx = otndx(objptr(obj)->oname, &objtab); |
73 |
< |
objtab.htab[ndx] = obj; |
72 |
> |
i = otndx(objptr(obj)->oname, &objtab); |
73 |
> |
objtab.htab[i] = obj; |
74 |
|
#endif |
75 |
|
if (ismodifier(objptr(obj)->otype)) { |
76 |
< |
ndx = otndx(objptr(obj)->oname, &modtab); |
77 |
< |
modtab.htab[ndx] = obj; |
76 |
> |
i = otndx(objptr(obj)->oname, &modtab); |
77 |
> |
modtab.htab[i] = obj; |
78 |
|
} |
79 |
+ |
for (i = 0; addobjnotify[i] != NULL; i++) |
80 |
+ |
(*addobjnotify[i])(obj); |
81 |
|
} |
82 |
|
|
83 |
|
|
135 |
|
tab->hsiz = nexthsiz(tab->hsiz); |
136 |
|
tab->htab = (OBJECT *)malloc(tab->hsiz*sizeof(OBJECT)); |
137 |
|
if (tab->htab == NULL) |
138 |
< |
error(SYSTEM, "out of memory in tputo"); |
138 |
> |
error(SYSTEM, "out of memory in otndx"); |
139 |
|
ndx = tab->hsiz; |
140 |
|
while (ndx--) /* empty it */ |
141 |
|
tab->htab[ndx] = OVOID; |
142 |
|
} |
143 |
|
/* look up object */ |
144 |
|
hval = shash(name); |
145 |
+ |
tryagain: |
146 |
|
for (i = 0; i < tab->hsiz; i++) { |
147 |
|
ndx = (hval + i*i) % tab->hsiz; |
148 |
|
if (tab->htab[ndx] == OVOID || |
159 |
|
tab->htab[i] = oldhtab[ndx]; |
160 |
|
} |
161 |
|
free((char *)oldhtab); |
162 |
< |
return(otndx(name, tab)); |
162 |
> |
goto tryagain; /* should happen only once! */ |
163 |
|
} |