initialise param_beg and param_end before they will be used,
instead of "afterwards" in preparation for the next following usage.
and move the "comment out" up some lines, think that way:
comment out original line, append new line, ...
Traversing all linked memory structures to free their memory
can be a somewhat lengthy business, especially in xspice,
which is not worth the effort when we simply want to exit()
Long delays have been reported in certain cases.
For developers and for the usage of such tools as valgrind,
we still free all the memory if 'set ngdebug' is given.
which silently dropped the
here->initialized = MIF_FALSE
aspect of the MIFunsetup() function
which caused segfault in testcase
examples/memristor/memristor_x.sp
which have been invalidated by commit:
ifparm, #4/16, missing IF_REDUNDANT for some aliases, introduce IOPAPR
before this commit, sensitivity to "capacitance" was published twice,
once with name "c1" (reference name of a CAP device)
and as "c1_c" (reference name of a CAP concatenated with param name "c")
after said commit, sensitivity is no longer published as "c1_c"
(because "c" is only an "alias"/IF_REDUNDANT of the main parameter
which is named "capacitance", and "capacitance" is a IF_PRINCIPAL
and thus avoids "concatenation" of the parameter name)
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.
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.
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 simple cases,
which are local node variables which will start with value 0
and eventually be set with the result of a CKTmk..() invocation.
More complex cases evolve, if such a local variable might receive
a node number which origins from another node, or the netlist itself.
Invoke CKTdltNNum() in reverse order of local node creation in XXXsetup()
This fixes a bug at least in mesa and hfet1,
where already destroyed node variables have still been accessed
in the guarding 'if' of a later CKTdltNNum() stanza.
Invoking them in revers order easily prevents such bugs,
and improves readability.
Consider the following silent contracts:
1)
CKTsetup() invocations must be separated by a CKTunsetup() invocation
But CKTsetup() has an internal flag,
which will prevent re-invocation of DEVsetup()
But DEVsetup() will be called during sensitivity analysis,
bypassing this precaution. It is fatal if this will
cause another node allocation (CKTmk..()).
This commit tries to detect such cases.
(Note: many DEVsetup routines (all ?) have their CKTmk..() invocations
guarded to avoid reallocation of local nodes,
see commit f7f454c0a1
bug fix, fix the guard for device generated internal nodes (via CKTmkVolt())
)
FIXME:
DEVsetup() is seriously obfuscated by these guards.
If would be far better, if the sensitivity analysis
wouldn't sidestep into DEVsetup()
consider a device local variant of the CKTisSetup flag
2)
DEVunsetup() must delete all, each and every,
local allocated node in DEVsetup()
Otherwise CKTmk..() invocations in a following CKTsetup() will
return duplicate node numbers, effectively shorting device nodes.
This commit tries to detect incomplete CKTdltNNum() invocations.
3)
DEVunsetup() must not delete a netlist node.
This can easily happen in those devices which have optional ports,
which have code in DEVsetup() which copies node numbers to
local node variables.
This commit tries to detect such errors.