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 "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(op) /* free unneeded memory for object */ |
27 |
< |
register OBJREC *op; |
26 |
> |
free_os( /* free unneeded memory for object */ |
27 |
> |
OBJREC *op |
28 |
> |
) |
29 |
|
{ |
30 |
|
if (op->os == NULL) |
31 |
|
return(0); |
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 |
< |
case MAT_SPOT: /* spot light source */ |
50 |
< |
return(0); |
51 |
< |
default: |
65 |
> |
} |
66 |
|
#ifdef DEBUG |
67 |
< |
objerror(op, WARNING, "cannot free structure"); |
67 |
> |
objerror(op, WARNING, "cannot free structure"); |
68 |
|
#endif |
69 |
< |
return(0); |
56 |
< |
} |
69 |
> |
return(0); |
70 |
|
} |
71 |
|
|
72 |
|
|
73 |
|
int |
74 |
< |
free_objs(on, no, rn) /* free no object structures starting w/ on */ |
75 |
< |
register OBJECT on; |
76 |
< |
OBJECT no; |
77 |
< |
long rn; |
74 |
> |
free_objs( /* free some object structures */ |
75 |
> |
OBJECT on, |
76 |
> |
OBJECT no |
77 |
> |
) |
78 |
|
{ |
79 |
|
int nfreed; |
80 |
< |
register OBJREC *op; |
80 |
> |
OBJREC *op; |
81 |
|
|
82 |
|
for (nfreed = 0; no-- > 0; on++) { |
83 |
|
op = objptr(on); |
84 |
< |
if (op->os != NULL && op->lastrno < rn) |
84 |
> |
if (op->os != NULL) |
85 |
|
nfreed += free_os(op); |
86 |
|
} |
87 |
|
return(nfreed); |
88 |
|
} |
89 |
|
|
90 |
|
|
91 |
< |
free_objmem() /* free all object cache memory */ |
91 |
> |
void |
92 |
> |
free_objmem(void) /* free all object cache memory */ |
93 |
|
{ |
94 |
< |
extern long raynum; |
81 |
< |
|
82 |
< |
free_objs(0, nobjects, raynum); |
94 |
> |
free_objs(0, nobjects); |
95 |
|
freedata(NULL); |
84 |
– |
freepict(NULL); |
96 |
|
freefont(NULL); |
97 |
+ |
SDfreeCache(NULL); |
98 |
|
} |