--- ray/src/rt/preload.c 2013/11/08 17:11:42 2.13 +++ ray/src/rt/preload.c 2017/07/14 23:19:32 2.14 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: preload.c,v 2.13 2013/11/08 17:11:42 greg Exp $"; +static const char RCSid[] = "$Id: preload.c,v 2.14 2017/07/14 23:19:32 greg Exp $"; #endif /* * Preload associated object structures to maximize memory sharing. @@ -28,8 +28,11 @@ load_os( /* load associated data for object */ OBJREC *op ) { - DATARRAY *dp; + DATARRAY *dp; + SDData *sd; + SDretainSet = SDretainAll; + switch (op->otype) { case OBJ_FACE: /* polygon */ getface(op); @@ -104,7 +107,8 @@ load_os( /* load associated data for object */ if (op->oargs.nsargs < 6) goto sargerr; getfunc(op, 5, 0x1d, 1); - loadBSDF(op->oargs.sarg[1]); + sd = loadBSDF(op->oargs.sarg[1]); + if (sd != NULL) SDfreeCache(sd); return(1); case MAT_PDATA: /* plastic BRDF data */ case MAT_MDATA: /* metal BRDF data */