Add a correction to the previous change of inppas4.c, which freed devname and left instance name pointers in DEVnameHash pointing at freed memory. This commit adds the devname string to the symbol tables which are eventually cleared by INPtabEnd. Also, if a capacitor in the spice netlist has the same name (unlikely, but possible) as a shunt capacitor, then no shunt is created, and a warning is issued.

This commit is contained in:
Brian Taylor 2025-09-27 12:16:39 -07:00 committed by Holger Vogt
parent 766c8d15e2
commit 71614dba3a
1 changed files with 18 additions and 2 deletions

View File

@ -57,8 +57,24 @@ void INPpas4(CKTcircuit *ckt, INPtables *tab)
int nn = node->number;
char* devname = tprintf("capac%dshunt", nn);
(*(ft_sim->newInstance))(ckt, tab->defCmod, &fast, devname);
txfree(devname);
fast = (*(ft_sim->findInstance))(ckt, devname);
if (fast) {
fprintf(stderr,
"WARNING: non-cshunt instance %s already exists\n",
devname);
tfree(devname);
continue;
}
error = (*(ft_sim->newInstance))(ckt, tab->defCmod, &fast, devname);
if (error) {
fprintf(stderr,
"ERROR: cshunt newInstance status %d devname %s\n",
error, devname);
tfree(devname);
continue;
}
/* devname is eventually freed when INPtabEnd is called */
INPinsert(&devname, tab);
/* the top node, second node is gnd automatically */
(*(ft_sim->bindNode))(ckt, fast, 1, node);