extend commit: spicelib/devcies/*dest.c, rewrite DEVdestroy() functions
rewrite admst/ngspiceMODULEdest.c.xml too, see commit
> commit 4d79617cf1
> Date: Fri Jul 29 22:22:16 2016 +0200
>
> spicelib/devcies/*dest.c, rewrite DEVdestroy() functions
This commit is contained in:
parent
88c50afcd9
commit
efbb7badbc
|
|
@ -40,35 +40,29 @@
|
||||||
<admst:template match="code">
|
<admst:template match="code">
|
||||||
<admst:value-of select="attribute[name='ngspicename']/value"/>
|
<admst:value-of select="attribute[name='ngspicename']/value"/>
|
||||||
<admst:variable name="module" select="%s"/>
|
<admst:variable name="module" select="%s"/>
|
||||||
|
|
||||||
#include "ngspice/ngspice.h"
|
#include "ngspice/ngspice.h"
|
||||||
#include "$(module)defs.h"
|
#include "$(module)defs.h"
|
||||||
#include "ngspice/suffix.h"
|
#include "ngspice/suffix.h"
|
||||||
|
|
||||||
void $(module)destroy(GENmodel **inModel)
|
void
|
||||||
|
$(module)destroy(GENmodel **inModel)
|
||||||
{
|
{
|
||||||
register $(module)model **model = ($(module)model**)inModel;
|
$(module)model *mod = *($(module)model**) inModel;
|
||||||
register $(module)instance *here;
|
|
||||||
$(module)instance *prev = NULL;
|
|
||||||
$(module)model *mod = *model;
|
|
||||||
$(module)model *oldmod = NULL;
|
|
||||||
|
|
||||||
for ( ; mod ; mod = mod->$(module)nextModel ) {
|
|
||||||
if (oldmod) FREE(oldmod);
|
|
||||||
oldmod = mod;
|
|
||||||
prev = ($(module)instance *)NULL;
|
|
||||||
for (here = mod->$(module)instances; here ; here = here->$(module)nextInstance) {
|
|
||||||
if(prev) FREE(prev);
|
|
||||||
prev = here;
|
|
||||||
}
|
|
||||||
if(prev) FREE(prev);
|
|
||||||
}
|
|
||||||
if(oldmod) FREE(oldmod);
|
|
||||||
*model = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
while (mod) {
|
||||||
|
$(module)model *next_mod = mod->$(module)nextModel;
|
||||||
|
$(module)instance *inst = mod->$(module)instances;
|
||||||
|
while (inst) {
|
||||||
|
$(module)instance *next_inst = inst->$(module)nextInstance;
|
||||||
|
FREE(inst);
|
||||||
|
inst = next_inst;
|
||||||
|
}
|
||||||
|
FREE(mod);
|
||||||
|
mod = next_mod;
|
||||||
|
}
|
||||||
|
|
||||||
|
*inModel = NULL;
|
||||||
|
}
|
||||||
</admst:template>
|
</admst:template>
|
||||||
|
|
||||||
<admst:for-each select="/module">
|
<admst:for-each select="/module">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue