--- ray/src/common/otypes.c 1989/02/02 10:34:38 1.1 +++ ray/src/common/otypes.c 1990/01/12 11:15:40 1.4 @@ -17,6 +17,8 @@ static char SCCSid[] = "$SunId$ LBL"; #include "otypes.h" +extern int (*addobjnotify[])(); /* people to notify of new objects */ + FUN ofun[NUMOTYPE] = INIT_OTYPE; /* our object function table */ static struct ohtab { @@ -66,16 +68,18 @@ char *mname; insertobject(obj) /* insert new object into our list */ register OBJECT obj; { - register int ndx; + register int i; #ifdef GETOBJ - ndx = otndx(objptr(obj)->oname, &objtab); - objtab.htab[ndx] = obj; + i = otndx(objptr(obj)->oname, &objtab); + objtab.htab[i] = obj; #endif if (ismodifier(objptr(obj)->otype)) { - ndx = otndx(objptr(obj)->oname, &modtab); - modtab.htab[ndx] = obj; + i = otndx(objptr(obj)->oname, &modtab); + modtab.htab[i] = obj; } + for (i = 0; addobjnotify[i] != NULL; i++) + (*addobjnotify[i])(obj); } @@ -133,13 +137,14 @@ register struct ohtab *tab; tab->hsiz = nexthsiz(tab->hsiz); tab->htab = (OBJECT *)malloc(tab->hsiz*sizeof(OBJECT)); if (tab->htab == NULL) - error(SYSTEM, "out of memory in tputo"); + error(SYSTEM, "out of memory in otndx"); ndx = tab->hsiz; while (ndx--) /* empty it */ tab->htab[ndx] = OVOID; } /* look up object */ hval = shash(name); +tryagain: for (i = 0; i < tab->hsiz; i++) { ndx = (hval + i*i) % tab->hsiz; if (tab->htab[ndx] == OVOID || @@ -156,5 +161,5 @@ register struct ohtab *tab; tab->htab[i] = oldhtab[ndx]; } free((char *)oldhtab); - return(otndx(name, tab)); + goto tryagain; /* should happen only once! */ }