devices/**/XXXmdel.c, fix adms too

This commit is contained in:
rlar 2018-01-07 15:46:54 +01:00
parent 982ba45bab
commit 8ba1999d15
1 changed files with 23 additions and 28 deletions

View File

@ -40,41 +40,36 @@
<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/sperror.h&quot;
#include &quot;ngspice/suffix.h&quot;
int $(module)mDelete(GENmodel **inModel, IFuid modname, GENmodel *kill)
int
$(module)mDelete(GENmodel **models, IFuid modname, GENmodel *kill)
{
register $(module)model **model = ($(module)model**)inModel;
register $(module)model *modfast =($(module)model*)kill;
$(module)instance *here;
$(module)instance *prev = NULL;
$(module)model **oldmod;
oldmod = model;
for ( ; *model ; model = &amp;((*model)->$(module)nextModel)) {
if ((*model)->$(module)modName == modname ||
(modfast &amp;&amp; *model == modfast))
goto delgot;
oldmod = model;
}
return(E_NOMOD);
delgot:
*oldmod = (*model)->$(module)nextModel; /* cut deleted device out of list */
for (here = (*model)->$(module)instances; here; here = here->$(module)nextInstance)
{ if(prev) FREE(prev);
prev = here;
}
if(prev) FREE(prev);
FREE(*model);
return(OK);
}
GENinstance *here;
GENmodel **prev = models;
GENmodel *model = *prev;
for (; model; model = model->GENnextModel) {
if (model->GENmodName == modname || (kill &amp;&amp; model == kill))
break;
prev = &amp;(model->GENnextModel);
}
if (!model)
return E_NOMOD;
*prev = model->GENnextModel;
for (here = model->GENinstances; here;) {
GENinstance *next_instance = here->GENnextInstance;
FREE(here);
here = next_instance;
}
FREE(model);
return OK;
}
</admst:template>
<admst:for-each select="/module">