--- ray/src/common/modobject.c 1998/11/05 16:51:26 2.6 +++ ray/src/common/modobject.c 2003/07/17 09:21:29 2.10 @@ -1,13 +1,14 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: modobject.c,v 2.10 2003/07/17 09:21:29 schorsch Exp $"; #endif - /* * Routines for tracking object modifiers + * + * External symbols declared in object.h */ +#include "copyright.h" + #include "standard.h" #include "object.h" @@ -15,17 +16,15 @@ static char SCCSid[] = "$SunId$ LBL"; #include "otypes.h" -extern int (*addobjnotify[])(); /* people to notify of new objects */ - static struct ohtab { int hsiz; /* current table size */ OBJECT *htab; /* table, if allocated */ } modtab = {100, NULL}, objtab = {1000, NULL}; /* modifiers and objects */ -static int otndx(); +static int otndx(char *, struct ohtab *); -int +OBJECT objndx(op) /* get object number from pointer */ register OBJREC *op; { @@ -40,7 +39,7 @@ register OBJREC *op; } -int +OBJECT lastmod(obj, mname) /* find modifier definition before obj */ OBJECT obj; char *mname; @@ -60,7 +59,7 @@ char *mname; } -int +OBJECT modifier(mname) /* get a modifier number from its name */ char *mname; { @@ -72,7 +71,7 @@ char *mname; #ifdef GETOBJ -int +OBJECT object(oname) /* get an object number from its name */ char *oname; { @@ -84,6 +83,7 @@ char *oname; #endif +void insertobject(obj) /* insert new object into our list */ register OBJECT obj; { @@ -104,6 +104,22 @@ register OBJECT obj; } +void +clearobjndx() /* clear object hash tables */ +{ + if (modtab.htab != NULL) { + free((void *)modtab.htab); + modtab.htab = NULL; + modtab.hsiz = 100; + } + if (objtab.htab != NULL) { + free((void *)objtab.htab); + objtab.htab = NULL; + objtab.hsiz = 100; + } +} + + static int nexthsiz(oldsiz) /* return next hash table size */ int oldsiz; @@ -156,6 +172,6 @@ tryagain: i = otndx(objptr(oldhtab[ndx])->oname, tab); tab->htab[i] = oldhtab[ndx]; } - free((char *)oldhtab); + free((void *)oldhtab); goto tryagain; /* should happen only once! */ }