From 8ba1999d15b3e5efb76edcdeca1790c10825ed90 Mon Sep 17 00:00:00 2001 From: rlar Date: Sun, 7 Jan 2018 15:46:54 +0100 Subject: [PATCH] devices/**/XXXmdel.c, fix adms too --- .../adms/admst/ngspiceMODULEmdel.c.xml | 51 +++++++++---------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/src/spicelib/devices/adms/admst/ngspiceMODULEmdel.c.xml b/src/spicelib/devices/adms/admst/ngspiceMODULEmdel.c.xml index 09029c833..cb7a5b371 100644 --- a/src/spicelib/devices/adms/admst/ngspiceMODULEmdel.c.xml +++ b/src/spicelib/devices/adms/admst/ngspiceMODULEmdel.c.xml @@ -40,41 +40,36 @@ - #include "ngspice/ngspice.h" #include "$(module)defs.h" #include "ngspice/sperror.h" #include "ngspice/suffix.h" -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 = &((*model)->$(module)nextModel)) { - if ((*model)->$(module)modName == modname || - (modfast && *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 && model == kill)) + break; + prev = &(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; +}