ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/bsdf.c
(Generate patch)

Comparing ray/src/common/bsdf.c (file contents):
Revision 2.19 by greg, Sat Apr 9 15:39:16 2011 UTC vs.
Revision 2.21 by greg, Sun Apr 17 17:45:13 2011 UTC

# Line 45 | Line 45 | int                    SDretainSet = SDretainNone;
45   SDError
46   SDreportEnglish(SDError ec, FILE *fp)
47   {
48        if (fp == NULL)
49                return ec;
48          if (!ec)
49                  return SDEnone;
50 +        if ((ec < SDEnone) | (ec > SDEunknown)) {
51 +                SDerrorDetail[0] = '\0';
52 +                ec = SDEunknown;
53 +        }
54 +        if (fp == NULL)
55 +                return ec;
56          fputs(SDerrorEnglish[ec], fp);
57          if (SDerrorDetail[0]) {
58                  fputs(": ", fp);
# Line 269 | Line 273 | SDclipName(char *res, const char *fname)
273  
274   /* Initialize an unused BSDF struct (simply clears to zeroes) */
275   void
276 < SDclearBSDF(SDData *sd)
276 > SDclearBSDF(SDData *sd, const char *fname)
277   {
278 <        if (sd != NULL)
279 <                memset(sd, 0, sizeof(SDData));
278 >        if (sd == NULL)
279 >                return;
280 >        memset(sd, 0, sizeof(SDData));
281 >        if (fname == NULL)
282 >                return;
283 >        SDclipName(sd->name, fname);
284   }
285  
286   /* Free data associated with BSDF struct */
# Line 330 | Line 338 | SDgetCache(const char *bname)
338          sdl->next = SDcacheList;
339          SDcacheList = sdl;
340  
341 <        sdl->refcnt++;
341 >        sdl->refcnt = 1;
342          return &sdl->bsdf;
343   }
344  
# Line 374 | Line 382 | SDfreeCache(const SDData *sd)
382          for (sdl = SDcacheList; sdl != NULL; sdl = (sdLast=sdl)->next)
383                  if (&sdl->bsdf == sd)
384                          break;
385 <        if (sdl == NULL || --sdl->refcnt)
385 >        if (sdl == NULL || (sdl->refcnt -= (sdl->refcnt > 0)))
386                  return;                 /* missing or still in use */
387                                          /* keep unreferenced data? */
388          if (SDisLoaded(sd) && SDretainSet) {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines