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

Comparing ray/src/common/readobj.c (file contents):
Revision 2.5 by greg, Thu Jul 18 17:58:01 1996 UTC vs.
Revision 2.10 by greg, Mon Mar 10 17:13:29 2003 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1994 Regents of the University of California */
2
1   #ifndef lint
2 < static char SCCSid[] = "$SunId$ LBL";
2 > static const char RCSid[] = "$Id$";
3   #endif
6
4   /*
5   *  readobj.c - routines for reading in object descriptions.
6   *
7 < *     7/28/85
7 > *  External symbols declared in object.h
8   */
9  
10 + #include "copyright.h"
11 +
12   #include  "standard.h"
13  
14   #include  "object.h"
# Line 18 | Line 17 | static char SCCSid[] = "$SunId$ LBL";
17  
18   #include  <ctype.h>
19  
21 extern char  *fgetword(), *strcpy();
22
20   OBJREC  *objblock[MAXOBJBLK];           /* our objects */
21   OBJECT  nobjects = 0;                   /* # of objects */
22  
23  
24 + void
25   readobj(inpspec)                /* read in an object file or stream */
26   char  *inpspec;
27   {
30        FILE  *popen();
31        char  *fgetline();
28          OBJECT  lastobj;
29          FILE  *infp;
30          char  buf[1024];
# Line 72 | Line 68 | char  *inpspec;
68   }
69  
70  
71 + void
72   getobject(name, fp)                     /* read the next object */
73   char  *name;
74   FILE  *fp;
# Line 133 | Line 130 | FILE  *fp;
130   }
131  
132  
133 < int
133 > OBJECT
134   newobject()                             /* get a new object */
135   {
136          register int  i;
137  
138 <        if ((nobjects & 077) == 0) {            /* new block */
138 >        if ((nobjects & (OBJBLKSIZ-1)) == 0) {  /* new block */
139                  errno = 0;
140 <                i = nobjects >> 6;
140 >                i = nobjects >> OBJBLKSHFT;
141                  if (i >= MAXOBJBLK)
142                          return(OVOID);
143 <                objblock[i] = (OBJREC *)bmalloc(0100*sizeof(OBJREC));
143 >                objblock[i] = (OBJREC *)calloc(OBJBLKSIZ, sizeof(OBJREC));
144                  if (objblock[i] == NULL)
145                          return(OVOID);
146          }
147          return(nobjects++);
148 + }
149 +
150 + void
151 + freeobjects(firstobj, nobjs)            /* free a range of objects */
152 + OBJECT  firstobj, nobjs;
153 + {
154 +        register int  obj;
155 +                                        /* check bounds */
156 +        if (firstobj < 0)
157 +                return;
158 +        if (nobjs <= 0)
159 +                return;
160 +        if (firstobj + nobjs > nobjects)
161 +                return;
162 +                                        /* clear objects */
163 +        for (obj = firstobj+nobjs; obj-- > firstobj; ) {
164 +                register OBJREC  *o = objptr(obj);
165 +                free_os(o);             /* free client memory */
166 +                freeqstr(o->oname);
167 +                freefargs(&o->oargs);
168 +                bzero(o, sizeof(OBJREC));
169 +        }
170 +        clearobjndx();
171 +                                        /* free objects off end */
172 +        for (obj = nobjects; obj-- > 0; )
173 +                if (objptr(obj)->oname != NULL)
174 +                        break;
175 +        ++obj;
176 +        while (nobjects > obj)          /* free empty end blocks */
177 +                if ((--nobjects & (OBJBLKSIZ-1)) == 0) {
178 +                        int     i = nobjects >> OBJBLKSHFT;
179 +                        free((void *)objblock[i]);
180 +                        objblock[i] = NULL;
181 +                }
182   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines