--- ray/src/common/lookup.c 2003/06/30 14:59:11 2.9 +++ ray/src/common/lookup.c 2003/11/21 07:15:29 2.12 @@ -1,25 +1,16 @@ #ifndef lint -static const char RCSid[] = "$Id: lookup.c,v 2.9 2003/06/30 14:59:11 schorsch Exp $"; +static const char RCSid[] = "$Id: lookup.c,v 2.12 2003/11/21 07:15:29 greg Exp $"; #endif /* * Table lookup routines */ -#include "copyright.h" - #include #include -#include #include "lookup.h" -#ifdef NOSTRUCTASS -#define copystruct(d,s) memcpy((void *)(d),(void *)(s),sizeof(*(d))) -#else -#define copystruct(d,s) (*(d) = *(s)) -#endif - int lu_init(tbl, nel) /* initialize tbl for at least nel elements */ register LUTAB *tbl; @@ -131,11 +122,12 @@ 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((void *)le); goto tryagain; /* should happen only once! */ } @@ -162,17 +154,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); }