memory bug corrected
This commit is contained in:
13
tecs/tecs.c
13
tecs/tecs.c
@@ -161,7 +161,7 @@ int instCurve(char *nam, char *channel) {
|
||||
str_append(buf, " ");
|
||||
str_upcase(buf, buf);
|
||||
|
||||
if (cache==NULL) { cache=malloc(1); *cache='\0'; } /* create empty cache if undefined */
|
||||
if (cache==NULL) { ERR_SP(cache=my_malloc(1,"one")); *cache='\0'; } /* create empty cache if undefined */
|
||||
start=strchr(cache, '\n'); /* skip device names */
|
||||
if (start==NULL) { start=cache; } else { start++; }
|
||||
entry=strstr(start, buf);
|
||||
@@ -251,7 +251,7 @@ int instCurve(char *nam, char *channel) {
|
||||
logfileOut(LOG_MAIN, "curve selected on channel %s\n", chan);
|
||||
saveTime=tim+30;
|
||||
}
|
||||
free(crv); crv=NULL;
|
||||
my_free(crv); crv=NULL;
|
||||
|
||||
if (num<=20) return(0); /* standard curve, do not touch cache */
|
||||
|
||||
@@ -276,15 +276,16 @@ int instCurve(char *nam, char *channel) {
|
||||
ERR_SI(fputs("\n", fil));
|
||||
ERR_SI(fputs(e, fil));
|
||||
}
|
||||
ERR_SI(fputc('\0', fil));
|
||||
ERR_SI(fclose(fil));
|
||||
fil=NULL;
|
||||
free(cache);
|
||||
my_free(cache);
|
||||
/* re-read it */
|
||||
ERR_P(cache=str_read_file(nbuf));
|
||||
return(0);
|
||||
|
||||
OnError:
|
||||
if (crv!=NULL) free(crv);
|
||||
if (crv!=NULL) my_free(crv);
|
||||
if (fil!=NULL) fclose(fil);
|
||||
return(retstat);
|
||||
}
|
||||
@@ -303,7 +304,7 @@ int configInput() {
|
||||
sprintf(buf, "%+d ", testpoint->code);
|
||||
if (testpoint->code==0) return(0);
|
||||
}
|
||||
if (table!=NULL && tim>tableTime+60) { free(table); table=NULL; }; /* clear old table */
|
||||
if (table!=NULL && tim>tableTime+60) { my_free(table); table=NULL; }; /* clear old table */
|
||||
if (table==NULL) { /* read table */
|
||||
str_copy(nbuf, binDir);
|
||||
str_append(nbuf, TABLE_FILE);
|
||||
@@ -520,7 +521,7 @@ int PeriodicTask() {
|
||||
if (samp.manual || samp.code!=0) { samp.dirty=1; }
|
||||
ERR_P(LscCmd(ser, "RANGE:0")); /* switch off heater */
|
||||
/* reload curve cache: */
|
||||
if (cache!=NULL) free(cache);
|
||||
if (cache!=NULL) my_free(cache);
|
||||
sprintf(lbuf, "lsc.%d", serialNo);
|
||||
str_copy(buf, logDir);
|
||||
str_append(buf, lbuf);
|
||||
|
||||
Reference in New Issue
Block a user