--- ray/src/rt/freeobjmem.c 1992/11/22 10:58:10 2.1 +++ ray/src/rt/freeobjmem.c 2004/03/30 16:13:01 2.7 @@ -1,21 +1,30 @@ -/* Copyright (c) 1992 Regents of the University of California */ - #ifndef lint -static char SCCSid[] = "$SunId$ LBL"; +static const char RCSid[] = "$Id: freeobjmem.c,v 2.7 2004/03/30 16:13:01 schorsch Exp $"; #endif - /* * Free memory associated with object(s) + * + * External symbols declared in ray.h */ -#include "standard.h" -#include "object.h" +#include "copyright.h" + +#include "ray.h" #include "otypes.h" +#include "rtotypes.h" +#include "face.h" +#include "cone.h" +#include "instance.h" +#include "data.h" +#include "font.h" +#include "func.h" +#include "mesh.h" -int -free_os(op) /* free unneeded memory for object */ -register OBJREC *op; +extern int +free_os( /* free unneeded memory for object */ + register OBJREC *op +) { if (op->os == NULL) return(0); @@ -37,50 +46,49 @@ register OBJREC *op; case OBJ_INSTANCE: /* octree instance */ freeinstance(op); return(1); + case OBJ_MESH: /* mesh instance */ + freemeshinst(op); + return(1); case PAT_BTEXT: /* monochromatic text */ case PAT_CTEXT: /* colored text */ case MIX_TEXT: /* mixing text */ freetext(op); return(1); case MAT_CLIP: /* clipping surface */ - free(op->os); + case MAT_SPOT: /* spot light source */ + free((void *)op->os); op->os = NULL; return(1); - case MAT_SPOT: /* spot light source */ - return(0); - default: + } #ifdef DEBUG - objerror(op, WARNING, "cannot free structure"); + objerror(op, WARNING, "cannot free structure"); #endif - return(0); - } + return(0); } -int -free_objs(on, no, rn) /* free no object structures starting w/ on */ -register OBJECT on; -OBJECT no; -long rn; +extern int +free_objs( /* free some object structures */ + register OBJECT on, + OBJECT no +) { int nfreed; register OBJREC *op; for (nfreed = 0; no-- > 0; on++) { op = objptr(on); - if (op->os != NULL && op->lastrno < rn) + if (op->os != NULL) nfreed += free_os(op); } return(nfreed); } -free_objmem() /* free all object cache memory */ +extern void +free_objmem(void) /* free all object cache memory */ { - extern long raynum; - - free_objs(0, nobjects, raynum); + free_objs(0, nobjects); freedata(NULL); - freepict(NULL); freefont(NULL); }