Back to index

radiance  4R0+20100331
free_os.c
Go to the documentation of this file.
00001 #ifndef lint
00002 static const char    RCSid[] = "$Id: free_os.c,v 3.4 2003/07/17 09:21:29 schorsch Exp $";
00003 #endif
00004 /*
00005  * Free memory associated with object(s)
00006  *
00007  *   External symbols declared in object.h
00008  */
00009 
00010 #include "copyright.h"
00011 
00012 #include "standard.h"
00013 #include "octree.h"
00014 #include "object.h"
00015 #include "otypes.h"
00016 #include "face.h"
00017 #include "cone.h"
00018 #include "instance.h"
00019 #include "mesh.h"
00020 
00021 
00022 int
00023 free_os(op)                 /* free unneeded memory for object */
00024 register OBJREC      *op;
00025 {
00026        if (op->os == NULL)
00027               return(0);
00028        switch (op->otype) {
00029        case OBJ_FACE:              /* polygon */
00030               freeface(op);
00031               return(1);
00032        case OBJ_CONE:              /* cone */
00033        case OBJ_RING:              /* disk */
00034        case OBJ_CYLINDER:   /* cylinder */
00035        case OBJ_CUP:        /* inverted cone */
00036        case OBJ_TUBE:              /* inverted cylinder */
00037               freecone(op);
00038               return(1);
00039        case OBJ_INSTANCE:   /* octree instance */
00040               freeinstance(op);
00041               return(1);
00042        case OBJ_MESH:              /* mesh instance */
00043               freemeshinst(op);
00044               return(1);
00045        }
00046                             /* don't really know */
00047        free((void *)op->os);
00048        op->os = NULL;
00049        return(1);
00050 }