extend commit: spicelib/devcies/*dest.c, rewrite DEVdestroy() functions

This commit is contained in:
rlar 2018-01-08 19:55:27 +01:00
parent dcd96634f7
commit b511a9179a
1 changed files with 17 additions and 23 deletions

View File

@ -40,35 +40,29 @@
<admst:template match="code">
<admst:value-of select="attribute[name='ngspicename']/value"/>
<admst:variable name="module" select="%s"/>
#include &quot;ngspice/ngspice.h&quot;
#include &quot;$(module)defs.h&quot;
#include &quot;ngspice/suffix.h&quot;
void $(module)destroy(GENmodel **inModel)
void
$(module)destroy(GENmodel **inModel)
{
register $(module)model **model = ($(module)model**)inModel;
register $(module)instance *here;
$(module)instance *prev = NULL;
$(module)model *mod = *model;
$(module)model *oldmod = NULL;
for ( ; mod ; mod = $(module)nextModel(mod) ) {
if (oldmod) FREE(oldmod);
oldmod = mod;
prev = ($(module)instance *)NULL;
for (here = $(module)instances(mod); here ; here = here->$(module)nextInstance) {
if(prev) FREE(prev);
prev = here;
}
if(prev) FREE(prev);
}
if(oldmod) FREE(oldmod);
*model = NULL;
return;
}
$(module)model *mod = *($(module)model**) inModel;
while (mod) {
$(module)model *next_mod = $(module)nextModel(mod);
$(module)instance *inst = $(module)instances(mod);
while (inst) {
$(module)instance *next_inst = inst-&gt;$(module)nextInstance;
FREE(inst);
inst = next_inst;
}
FREE(mod);
mod = next_mod;
}
*inModel = NULL;
}
</admst:template>
<admst:for-each select="/module">