--- ray/src/common/lookup.c 1998/09/03 14:22:23 2.5 +++ ray/src/common/lookup.c 2003/07/30 10:11:06 2.11 @@ -1,27 +1,18 @@ -/* Copyright (c) 1998 Silicon Graphics, Inc. */ - #ifndef lint -static char SCCSid[] = "$SunId$ SGI"; +static const char RCSid[] = "$Id: lookup.c,v 2.11 2003/07/30 10:11:06 schorsch Exp $"; #endif - /* * Table lookup routines */ +#include "copyright.h" + #include +#include + #include "lookup.h" -#ifdef NOSTRUCTASS -#define copystruct(d,s) bcopy((char *)(s),(char *)(d),sizeof(*(d))) -#else -#define copystruct(d,s) (*(d) = *(s)) -#endif -#define MEM_PTR char * - -extern MEM_PTR calloc(); - - int lu_init(tbl, nel) /* initialize tbl for at least nel elements */ register LUTAB *tbl; @@ -133,12 +124,13 @@ tryagain: * recursive call to lu_find(). */ while (ndx--) - if (le[ndx].key != NULL) + if (le[ndx].key != NULL) { if (le[ndx].data != NULL) - copystruct(lu_find(tbl,le[ndx].key), &le[ndx]); + *lu_find(tbl,le[ndx].key) = le[ndx]; else if (tbl->freek != NULL) (*tbl->freek)(le[ndx].key); - free((MEM_PTR)le); + } + free((void *)le); goto tryagain; /* should happen only once! */ } @@ -164,17 +156,18 @@ char *key; int lu_doall(tbl, f) /* loop through all valid table entries */ register LUTAB *tbl; -int (*f)(); +int (*f)(LUENT *); { int rval = 0; register LUENT *tp; for (tp = tbl->tabl + tbl->tsiz; tp-- > tbl->tabl; ) - if (tp->data != NULL) + if (tp->data != NULL) { if (f != NULL) rval += (*f)(tp); else rval++; + } return(rval); } @@ -194,7 +187,7 @@ register LUTAB *tbl; if (tp->data != NULL && tbl->freed != NULL) (*tbl->freed)(tp->data); } - free((MEM_PTR)tbl->tabl); + free((void *)tbl->tabl); tbl->tabl = NULL; tbl->tsiz = 0; tbl->ndel = 0;