Allow to register a callback function in the cfunc.mod files,
which will be invoked in MIFdestroy.
Usefull to "free" memory which has been allocated locally in a cfunc.mod file.
src/spicelib/devices/*/*set.c, XXXunsetup(), reset local node variables unconditionally
and use a more robust test for local node numbers.
That is, transform this pattern :
if (here->Node && ...) {
CKTdltNNum(ckt, here->Node);
here->Node = 0;
}
into this :
if (here->Node > 0 && ...)
CKTdltNNum(ckt, here->Node);
here->Node = 0;
The change of "!= 0" ==> "> 0" accounts for rare cases where "Node"
might have been set to -1, (meaning "unconnected")
The unconditional execution of the zero assignment is for those cases
where "Node" might have been assigned to some external or other local Node.
If so, the variable would not be set to zero, confusing the "guarding" if's
in the corresponding XXXsetup() routine.
The Pattern to follow is:
1) unset and delete *all* local Nodes in XXXunsetup()
2) allocate all of them again in a re-invocation of XXXsetup(),
exactly the same way as in the very first invocation.
for almost all other external nodes (notable exception "txl")
src/spicelib/devices/*/*def*.h, declare external node variables const
1) The compiler shall emit an error message if we still mess around
with external node numbers.
2) To mark which elements of the instance struct are meant to be set
externally when parsing the netlist
These "external" node variables are exclusively set via the
overlay struct GENinstance, member GENnode[]
We shall not mess around with these "external" node variables
because it would get rather difficult to avoid bugs considering
re-invocation of the XXXsetup() routine.
This gets interesting for devices with optional ports,
which get copied around depending on the amount of connected ports.
All locally created nodes (CKTmk..() invocations in XXXsetup())
must be deleted in XXXunsetup()
Otherwise CKTmk..() invocations during a following CKTsetup()
will re-emit still used node numbers,
thus accidentally shorting nodes.
This patch fixes the complex cases,
which are external node variables (ports of the instance),
which might be moved over to other external node variables
to cope with optional port connections.
This is fixed by copying the node numbers to local shadow variables
to avoid messing with the external nodes.
Otherwise a following CKTsetup() might again meddle with the external
node variables, at least causing considerable confusion, probably causing
hard to find bugs.
src/spicelib/devices/*/*set.c, missing CKTdltNNum() invocations, medium cases
All locally created nodes (CKTmk..() invocations in XXXsetup())
must be deleted in XXXunsetup()
Otherwise CKTmk..() invocations during a following CKTsetup()
will re-emit still used node numbers,
thus accidentally shorting nodes.
This patch fixes a little bit more complex cases,
which are local node variables which will start with value 0
and eventually be set with the result of a CKTmk..() invocations,
but might as well receive a node number from another node variable.
Here CKTdltNNum() must not be invoked if the node number is merely
a copy from another node variable.