Completed and cleaned up memory leak fixes in:

inpc_probe.c outitf.c inpcom.c niiter.c
cherry-pick of this one commit should be OK.
This commit is contained in:
Brian Taylor 2026-05-18 22:17:40 -07:00
parent 5d391fa745
commit a2f081f89d
4 changed files with 18 additions and 4 deletions

View File

@ -48,6 +48,7 @@ void inp_probe(struct card* deck)
int skip_control = 0;
int skip_subckt = 0;
wordlist* probes = NULL, *probeparams = NULL, *wltmp, *allsaves = NULL;
wordlist *next_wl = NULL;
bool haveall = FALSE, havedifferential = FALSE, t = TRUE, havesave = FALSE;
NGHASHPTR instances; /* instance hash table */
int ee = 0; /* serial number for sources */
@ -140,7 +141,12 @@ void inp_probe(struct card* deck)
}
}
/* don't free the wl_word, they belong to the cards */
tfree(probes);
wltmp = probes;
while (wltmp) {
next_wl = wltmp->wl_next;
tfree(wltmp); // Do not free the wl_word
wltmp = next_wl;
}
/* Set up the hash table for all instances (instance name is key, data
is the storage location of the card) */
@ -188,6 +194,7 @@ void inp_probe(struct card* deck)
if (!instname)
continue;
nghash_insert(instances, instname, card);
tfree(instname);
}
if (haveall || probeparams == NULL) {
@ -886,6 +893,7 @@ void inp_probe(struct card* deck)
tmpcard = nghash_find(instances, instname);
if (!tmpcard) {
fprintf(stderr, "Warning: Could not find the instance line for %s,\n .probe %s will be ignored\n", instname, wltmp->wl_word);
tfree(instname);
continue;
}
char* thisline = tmpcard->line;
@ -921,6 +929,7 @@ void inp_probe(struct card* deck)
else if (err == 3) {
fprintf(stderr, "Warning: Number of nodes mismatch,\n .probe %s will be ignored\n", wltmp->wl_word);
}
tfree(instname);
continue;
}
else if (!haveall) {
@ -938,6 +947,9 @@ void inp_probe(struct card* deck)
}
}
if (probeparams) {
wl_free(probeparams);
}
nghash_free(instances, NULL, NULL);
}

View File

@ -9944,6 +9944,7 @@ int add_to_sourcepath(const char* filepath, const char* path)
scan_new = next;
}
if (!addwl) {
wl_free(startwl);
wl_free(wl);
tfree(fpath);
return 0; // Not an error.

View File

@ -153,11 +153,11 @@ OUTpBeginPlot(CKTcircuit *circuitPtr, JOB *analysisPtr,
" is more than the DRAM memory available (%sB)!\n",
cmemrequ, n, ctimesteps, cmemavail);
fprintf(stderr, " Swapping data to SSD may slow down the simulation.\n");
tfree(cmemrequ);
tfree(cmemavail);
tfree(ctimesteps);
#endif
}
tfree(cmemrequ);
tfree(cmemavail);
tfree(ctimesteps);
}
return ret;

View File

@ -278,6 +278,7 @@ NIiter(CKTcircuit *ckt, int maxIter)
fprintf(stderr, "too many iterations without convergence: %d iter's (max iter == %d)\n",
iterno, maxIter);
#endif
FREE(errMsg);
}
FREE(OldCKTstate0);
return(E_ITERLIM);