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

Comparing ray/src/cv/mgflib/lookup.c (file contents):
Revision 1.9 by schorsch, Sun Jul 27 22:12:02 2003 UTC vs.
Revision 1.10 by schorsch, Sat Nov 15 17:54:06 2003 UTC

# Line 5 | Line 5 | static const char      RCSid[] = "$Id$";
5   * Table lookup routines
6   */
7  
8 + #include "copyright.h"
9 +
10   #include <stdio.h>
11   #include <stdlib.h>
12 +
13   #include "lookup.h"
14  
12 #ifndef MEM_PTR
13 #define MEM_PTR         void *
14 #endif
15  
16
16   int
17   lu_init(tbl, nel)               /* initialize tbl for at least nel elements */
18   register LUTAB  *tbl;
# Line 75 | Line 74 | char   *s;
74          register unsigned char *t = (unsigned char *)s;
75  
76          while (*t)
77 <                h ^= (long)shuffle[*t++] << ((i+=11) & 0xf);
77 >                h ^= (unsigned long)shuffle[*t++] << ((i+=11) & 0xf);
78  
79          return(h);
80   }
# Line 127 | Line 126 | tryagain:
126          while (ndx--)
127                  if (le[ndx].key != NULL) {
128                          if (le[ndx].data != NULL)
129 <                                *lu_find(tbl, le[ndx].key) = le[ndx];
129 >                                *lu_find(tbl,le[ndx].key) = le[ndx];
130                          else if (tbl->freek != NULL)
131                                  (*tbl->freek)(le[ndx].key);
132                  }
133 <        free((MEM_PTR)le);
133 >        free((void *)le);
134          goto tryagain;                  /* should happen only once! */
135   }
136  
# Line 154 | Line 153 | char   *key;
153   }
154  
155  
156 + int
157 + lu_doall(tbl, f)                /* loop through all valid table entries */
158 + register LUTAB  *tbl;
159 + int     (*f)(LUENT *);
160 + {
161 +        int     rval = 0;
162 +        register LUENT  *tp;
163 +
164 +        for (tp = tbl->tabl + tbl->tsiz; tp-- > tbl->tabl; )
165 +                if (tp->data != NULL) {
166 +                        if (f != NULL)
167 +                                rval += (*f)(tp);
168 +                        else
169 +                                rval++;
170 +                }
171 +        return(rval);
172 + }
173 +
174 +
175   void
176   lu_done(tbl)                    /* free table and contents */
177   register LUTAB  *tbl;
# Line 169 | Line 187 | register LUTAB *tbl;
187                          if (tp->data != NULL && tbl->freed != NULL)
188                                  (*tbl->freed)(tp->data);
189                  }
190 <        free((MEM_PTR)tbl->tabl);
190 >        free((void *)tbl->tabl);
191          tbl->tabl = NULL;
192          tbl->tsiz = 0;
193          tbl->ndel = 0;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines