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

Comparing ray/src/rt/freeobjmem.c (file contents):
Revision 2.1 by greg, Sun Nov 22 10:58:10 1992 UTC vs.
Revision 2.7 by schorsch, Tue Mar 30 16:13:01 2004 UTC

# Line 1 | Line 1
1 /* Copyright (c) 1992 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   * Free memory associated with object(s)
6 + *
7 + * External symbols declared in ray.h
8   */
9  
10 < #include "standard.h"
11 < #include "object.h"
10 > #include "copyright.h"
11 >
12 > #include "ray.h"
13   #include "otypes.h"
14 + #include "rtotypes.h"
15 + #include "face.h"
16 + #include "cone.h"
17 + #include "instance.h"
18 + #include "data.h"
19 + #include "font.h"
20 + #include "func.h"
21 + #include "mesh.h"
22  
23  
24 < int
25 < free_os(op)                     /* free unneeded memory for object */
26 < register OBJREC *op;
24 > extern int
25 > free_os(                        /* free unneeded memory for object */
26 >        register OBJREC *op
27 > )
28   {
29          if (op->os == NULL)
30                  return(0);
# Line 37 | Line 46 | register OBJREC        *op;
46          case OBJ_INSTANCE:      /* octree instance */
47                  freeinstance(op);
48                  return(1);
49 +        case OBJ_MESH:          /* mesh instance */
50 +                freemeshinst(op);
51 +                return(1);
52          case PAT_BTEXT:         /* monochromatic text */
53          case PAT_CTEXT:         /* colored text */
54          case MIX_TEXT:          /* mixing text */
55                  freetext(op);
56                  return(1);
57          case MAT_CLIP:          /* clipping surface */
58 <                free(op->os);
58 >        case MAT_SPOT:          /* spot light source */
59 >                free((void *)op->os);
60                  op->os = NULL;
61                  return(1);
62 <        case MAT_SPOT:          /* spot light source */
50 <                return(0);
51 <        default:
62 >        }
63   #ifdef DEBUG
64 <                objerror(op, WARNING, "cannot free structure");
64 >        objerror(op, WARNING, "cannot free structure");
65   #endif
66 <                return(0);
56 <        }
66 >        return(0);
67   }
68  
69  
70 < int
71 < free_objs(on, no, rn)           /* free no object structures starting w/ on */
72 < register OBJECT on;
73 < OBJECT  no;
74 < long    rn;
70 > extern int
71 > free_objs(              /* free some object structures */
72 >        register OBJECT on,
73 >        OBJECT  no
74 > )
75   {
76          int     nfreed;
77          register OBJREC *op;
78  
79          for (nfreed = 0; no-- > 0; on++) {
80                  op = objptr(on);
81 <                if (op->os != NULL && op->lastrno < rn)
81 >                if (op->os != NULL)
82                          nfreed += free_os(op);
83          }
84          return(nfreed);
85   }
86  
87  
88 < free_objmem()                   /* free all object cache memory */
88 > extern void
89 > free_objmem(void)                       /* free all object cache memory */
90   {
91 <        extern long     raynum;
81 <        
82 <        free_objs(0, nobjects, raynum);
91 >        free_objs(0, nobjects);
92          freedata(NULL);
84        freepict(NULL);
93          freefont(NULL);
94   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines