ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/lookup.c
(Generate patch)

Comparing ray/src/common/lookup.c (file contents):
Revision 2.7 by greg, Tue Feb 25 02:47:21 2003 UTC vs.
Revision 2.12 by greg, Fri Nov 21 07:15:29 2003 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   * Table lookup routines
6   */
7  
8 #include "copyright.h"
9
8   #include <stdio.h>
9   #include <stdlib.h>
10 +
11   #include "lookup.h"
12  
14 #ifdef  NOSTRUCTASS
15 #define  copystruct(d,s)        bcopy((char *)(s),(char *)(d),sizeof(*(d)))
16 #else
17 #define  copystruct(d,s)        (*(d) = *(s))
18 #endif
13  
20
14   int
15   lu_init(tbl, nel)               /* initialize tbl for at least nel elements */
16   register LUTAB  *tbl;
# Line 129 | Line 122 | tryagain:
122           * recursive call to lu_find().
123           */
124          while (ndx--)
125 <                if (le[ndx].key != NULL)
125 >                if (le[ndx].key != NULL) {
126                          if (le[ndx].data != NULL)
127 <                                copystruct(lu_find(tbl,le[ndx].key), &le[ndx]);
127 >                                *lu_find(tbl,le[ndx].key) = le[ndx];
128                          else if (tbl->freek != NULL)
129                                  (*tbl->freek)(le[ndx].key);
130 +                }
131          free((void *)le);
132          goto tryagain;                  /* should happen only once! */
133   }
# Line 160 | Line 154 | char   *key;
154   int
155   lu_doall(tbl, f)                /* loop through all valid table entries */
156   register LUTAB  *tbl;
157 < int     (*f)();
157 > int     (*f)(LUENT *);
158   {
159          int     rval = 0;
160          register LUENT  *tp;
161  
162          for (tp = tbl->tabl + tbl->tsiz; tp-- > tbl->tabl; )
163 <                if (tp->data != NULL)
163 >                if (tp->data != NULL) {
164                          if (f != NULL)
165                                  rval += (*f)(tp);
166                          else
167                                  rval++;
168 +                }
169          return(rval);
170   }
171  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines