ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/freeobjmem.c
Revision: 2.5
Committed: Tue Feb 25 02:47:22 2003 UTC (21 years, 2 months ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: rad3R5
Changes since 2.4: +1 -56 lines
Log Message:
Replaced inline copyright notice with #include "copyright.h"

File Contents

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