--- ray/src/rt/func.c 2016/03/22 03:56:17 2.31 +++ ray/src/rt/func.c 2016/04/27 21:11:32 2.32 @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: func.c,v 2.31 2016/03/22 03:56:17 greg Exp $"; +static const char RCSid[] = "$Id: func.c,v 2.32 2016/04/27 21:11:32 greg Exp $"; #endif /* * func.c - interface to calcomp functions. @@ -37,7 +37,7 @@ static double l_erf(char *), l_erfc(char *), l_arg(ch void -initfunc() /* initialize function evaluation */ +initfunc(void) /* initialize function evaluation */ { if (!rayinitcal[0]) /* already done? */ return; @@ -67,16 +67,30 @@ initfunc() /* initialize function evaluation */ void set_eparams(char *prms) { - static char *last_params = NULL; + static char *last_params; + static int lplen = 0; + int len; char vname[RMAXWORD]; double value; char *cpd; /* check if already set */ - if ((prms == NULL) | (prms == last_params)) + if (prms == NULL || !*prms) return; - if (last_params != NULL && !strcmp(prms, last_params)) + if (lplen && !strcmp(prms, last_params)) return; - last_params = prms; /* assign each variable */ + len = strlen(prms); /* record new settings */ + if ((lplen != 0) & (lplen <= len)) { + free(last_params); + lplen = 0; + } + if (!lplen) { + lplen = len + 100; + last_params = (char *)malloc(lplen); + if (last_params == NULL) + error(SYSTEM, "out of memory in set_eparams()"); + } + strcpy(last_params, prms); + /* assign each variable */ while (*prms) { if (isspace(*prms)) { ++prms; continue;