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.13 by schorsch, Sun Mar 28 20:33:12 2004 UTC vs.
Revision 2.18 by greg, Fri Feb 18 00:40:25 2011 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7  
8   #include <stdio.h>
9   #include <stdlib.h>
10 + #include <string.h>
11  
12   #include "lookup.h"
13  
13 extern int
14 lu_strcmp(
15        const void *s1,
16        const void *s2
17 )
18 {
19        return strcmp((const char*)s1,(const char*)s2);
20 }
14  
15 < extern int
15 > int
16   lu_init(                /* initialize tbl for at least nel elements */
17          register LUTAB  *tbl,
18          int     nel
# Line 46 | Line 39 | lu_init(               /* initialize tbl for at least nel elements
39   }
40  
41  
42 < extern unsigned long
42 > unsigned long
43   lu_shash(                       /* hash a nul-terminated string */
44 <        void    *s
44 >        const char      *s
45   )
46   {
47          static unsigned char shuffle[256] = {
# Line 79 | Line 72 | lu_shash(                      /* hash a nul-terminated string */
72          };
73          register int    i = 0;
74          register unsigned long  h = 0;
75 <        register unsigned char *t = (unsigned char *)s;
75 >        register unsigned const char *t = (unsigned const char *)s;
76  
77          while (*t)
78                  h ^= (unsigned long)shuffle[*t++] << ((i+=11) & 0xf);
# Line 88 | Line 81 | lu_shash(                      /* hash a nul-terminated string */
81   }
82  
83  
84 < extern LUENT *
84 > LUENT *
85   lu_find(                /* find a table entry */
86          register LUTAB  *tbl,
87 <        char    *key
87 >        const char      *key
88   )
89   {
90          unsigned long   hval;
# Line 144 | Line 137 | tryagain:
137   }
138  
139  
140 < extern void
140 > void
141   lu_delete(              /* delete a table entry */
142          register LUTAB  *tbl,
143 <        char    *key
143 >        const char      *key
144   )
145   {
146          register LUENT  *le;
# Line 163 | Line 156 | lu_delete(             /* delete a table entry */
156   }
157  
158  
159 < extern int
159 > int
160   lu_doall(               /* loop through all valid table entries */
161 <        register LUTAB  *tbl,
162 <        //int   (*f)(LUENT *)
163 <        lut_doallf_t *f
161 >        register const LUTAB    *tbl,
162 >        /* int  (*f)(const LUENT *) */
163 >        lut_doallf_t *f,
164 >        void *p
165   )
166   {
167          int     rval = 0;
168 <        register LUENT  *tp;
168 >        register const LUENT    *tp;
169  
170          for (tp = tbl->tabl + tbl->tsiz; tp-- > tbl->tabl; )
171                  if (tp->data != NULL) {
172 <                        if (f != NULL)
173 <                                rval += (*f)(tp);
174 <                        else
172 >                        if (f != NULL) {
173 >                                int     r = (*f)(tp, p);
174 >                                if (r < 0)
175 >                                        return(-1);
176 >                                rval += r;
177 >                        } else
178                                  rval++;
179                  }
180          return(rval);
181   }
182  
183  
184 < extern void
184 > void
185   lu_done(                        /* free table and contents */
186          register LUTAB  *tbl
187   )

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines