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

Comparing src/common/modobject.c (file contents):
Revision 2.21 by greg, Fri Dec 6 20:30:15 2024 UTC vs.
Revision 2.24 by greg, Sat Jun 21 00:15:30 2025 UTC

# Line 17 | Line 17 | static const char RCSid[] = "$Id$";
17  
18  
19   static struct ohtab {
20 <        int  hsiz;                      /* current table size */
21 <        OBJECT  *htab;                  /* table, if allocated */
20 >        int     hsiz;                   /* current table size */
21 >        OBJECT  *htab;                  /* table, if allocated */
22   }  modtab = {100, NULL}, objtab = {1000, NULL}; /* modifiers and objects */
23  
24   static int  otndx(char *, struct ohtab *);
# Line 30 | Line 30 | objndx(                                /* get object number from pointer */
30   )
31   {
32          int     i;
33        ssize_t j;
33  
34 <        for (i = (nobjects-1)>>OBJBLKSHFT; i >= 0; i--) {
35 <                j = op - objblock[i];
36 <                if ((0 <= j) & (j < OBJBLKSIZ))
37 <                        return(((OBJECT)i<<OBJBLKSHFT) + (OBJECT)j);
38 <        }
34 >        for (i = (nobjects-1)>>OBJBLKSHFT; i >= 0; i--)
35 >                if ((objblock[i] <= op) & (op < objblock[i]+OBJBLKSIZ))
36 >                        return( ((OBJECT)i << OBJBLKSHFT) +
37 >                                        (OBJECT)(op - objblock[i]) );
38 >
39          return(OVOID);          /* not in our array -- may still be valid */
40   }
41  
# Line 48 | Line 47 | lastmod(                       /* find modifier definition before obj */
47   )
48   {
49          OBJREC  *op;
50 <        int  i;
50 >        OBJECT  i;
51  
52          i = modifier(mname);            /* try hash table first */
53          if ((obj == OVOID) | (i < obj))
54                  return(i);
55          for (i = obj; i-- > 0; ) {      /* need to search */
56                  op = objptr(i);
57 <                if (ismodifier(op->otype) && op->oname[0] == mname[0] &&
58 <                                        !strcmp(op->oname, mname))
57 >                if ((ismodifier(op->otype) != 0) & (op->oname[0] == mname[0])
58 >                                && !strcmp(op->oname, mname))
59                          return(i);
60          }
61          return(OVOID);
# Line 196 | Line 195 | truncobjndx(void)              /* remove bogus table entries past
195  
196          if (nobjects <= 0) {
197                  if (modtab.htab != NULL) {
198 <                        free((void *)modtab.htab);
198 >                        free(modtab.htab);
199                          modtab.htab = NULL;
200                          modtab.hsiz = 100;
201                  }
202                  if (objtab.htab != NULL) {
203 <                        free((void *)objtab.htab);
203 >                        free(objtab.htab);
204                          objtab.htab = NULL;
205                          objtab.hsiz = 100;
206                  }
# Line 278 | Line 277 | tryagain:
277                          i = otndx(onm, tab);
278                          tab->htab[i] = oldhtab[ndx];
279                  }
280 <        free((void *)oldhtab);
280 >        free(oldhtab);
281          goto tryagain;                  /* should happen only once! */
282   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines