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); |
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 */ |
338 |
|
sdl->next = SDcacheList; |
339 |
|
SDcacheList = sdl; |
340 |
|
|
341 |
< |
sdl->refcnt++; |
341 |
> |
sdl->refcnt = 1; |
342 |
|
return &sdl->bsdf; |
343 |
|
} |
344 |
|
|
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) { |