ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/freeobjmem.c
Revision: 2.1
Committed: Sun Nov 22 10:58:10 1992 UTC (31 years, 5 months ago) by greg
Content type: text/plain
Branch: MAIN
Log Message:
Initial revision

File Contents

# Content
1 /* Copyright (c) 1992 Regents of the University of California */
2
3 #ifndef lint
4 static char SCCSid[] = "$SunId$ LBL";
5 #endif
6
7 /*
8 * Free memory associated with object(s)
9 */
10
11 #include "standard.h"
12 #include "object.h"
13 #include "otypes.h"
14
15
16 int
17 free_os(op) /* free unneeded memory for object */
18 register OBJREC *op;
19 {
20 if (op->os == NULL)
21 return(0);
22 if (hasfunc(op->otype)) {
23 freefunc(op);
24 return(1);
25 }
26 switch (op->otype) {
27 case OBJ_FACE: /* polygon */
28 freeface(op);
29 return(1);
30 case OBJ_CONE: /* cone */
31 case OBJ_RING: /* disk */
32 case OBJ_CYLINDER: /* cylinder */
33 case OBJ_CUP: /* inverted cone */
34 case OBJ_TUBE: /* inverted cylinder */
35 freecone(op);
36 return(1);
37 case OBJ_INSTANCE: /* octree instance */
38 freeinstance(op);
39 return(1);
40 case PAT_BTEXT: /* monochromatic text */
41 case PAT_CTEXT: /* colored text */
42 case MIX_TEXT: /* mixing text */
43 freetext(op);
44 return(1);
45 case MAT_CLIP: /* clipping surface */
46 free(op->os);
47 op->os = NULL;
48 return(1);
49 case MAT_SPOT: /* spot light source */
50 return(0);
51 default:
52 #ifdef DEBUG
53 objerror(op, WARNING, "cannot free structure");
54 #endif
55 return(0);
56 }
57 }
58
59
60 int
61 free_objs(on, no, rn) /* free no object structures starting w/ on */
62 register OBJECT on;
63 OBJECT no;
64 long rn;
65 {
66 int nfreed;
67 register OBJREC *op;
68
69 for (nfreed = 0; no-- > 0; on++) {
70 op = objptr(on);
71 if (op->os != NULL && op->lastrno < rn)
72 nfreed += free_os(op);
73 }
74 return(nfreed);
75 }
76
77
78 free_objmem() /* free all object cache memory */
79 {
80 extern long raynum;
81
82 free_objs(0, nobjects, raynum);
83 freedata(NULL);
84 freepict(NULL);
85 freefont(NULL);
86 }