ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/freeobjmem.c
Revision: 2.11
Committed: Thu Apr 4 18:51:18 2024 UTC (4 weeks ago) by greg
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 2.10: +2 -2 lines
Log Message:
perf: Added missing data preload calls for multi-processing with spectra

File Contents

# Content
1 #ifndef lint
2 static const char RCSid[] = "$Id: freeobjmem.c,v 2.10 2023/11/15 18:02:52 greg Exp $";
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 "rtotypes.h"
15 #include "bsdf.h"
16 #include "face.h"
17 #include "cone.h"
18 #include "instance.h"
19 #include "data.h"
20 #include "font.h"
21 #include "func.h"
22 #include "mesh.h"
23
24
25 int
26 free_os( /* free unneeded memory for object */
27 OBJREC *op
28 )
29 {
30 if (op->os == NULL)
31 return(0);
32 if (hasfunc(op->otype)) {
33 freefunc(op);
34 return(1);
35 }
36 switch (op->otype) {
37 case OBJ_FACE: /* polygon */
38 freeface(op);
39 return(1);
40 case OBJ_CONE: /* cone */
41 case OBJ_RING: /* disk */
42 case OBJ_CYLINDER: /* cylinder */
43 case OBJ_CUP: /* inverted cone */
44 case OBJ_TUBE: /* inverted cylinder */
45 freecone(op);
46 return(1);
47 case OBJ_INSTANCE: /* octree instance */
48 freeinstance(op);
49 return(1);
50 case OBJ_MESH: /* mesh instance */
51 freemeshinst(op);
52 return(1);
53 case PAT_BTEXT: /* monochromatic text */
54 case PAT_CTEXT: /* colored text */
55 case MIX_TEXT: /* mixing text */
56 freetext(op);
57 return(1);
58 case MAT_CLIP: /* clipping surface */
59 case MAT_SPOT: /* spot light source */
60 case PAT_SPECTRUM: /* constant spectrum */
61 case PAT_SPECFILE: /* spectrum from data file */
62 free(op->os);
63 op->os = NULL;
64 return(1);
65 }
66 #ifdef DEBUG
67 objerror(op, WARNING, "cannot free structure");
68 #endif
69 return(0);
70 }
71
72
73 int
74 free_objs( /* free some object structures */
75 OBJECT on,
76 OBJECT no
77 )
78 {
79 int nfreed;
80 OBJREC *op;
81
82 for (nfreed = 0; no-- > 0; on++) {
83 op = objptr(on);
84 if (op->os != NULL)
85 nfreed += free_os(op);
86 }
87 return(nfreed);
88 }
89
90
91 void
92 free_objmem(void) /* free all object cache memory */
93 {
94 free_objs(0, nobjects);
95 freedata(NULL);
96 freefont(NULL);
97 SDfreeCache(NULL);
98 }