diff --git a/src/spicelib/devices/asrc/asrcmdel.c b/src/spicelib/devices/asrc/asrcmdel.c index b3c947798..2fe0bc25e 100644 --- a/src/spicelib/devices/asrc/asrcmdel.c +++ b/src/spicelib/devices/asrc/asrcmdel.c @@ -13,7 +13,6 @@ int ASRCmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -29,15 +28,13 @@ ASRCmDelete(GENmodel **model, IFuid modname, GENmodel *kill) *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; FREE(((ASRCinstance*)here)->ASRCacValues); - if (prev) - FREE(prev); - prev = here; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/bsim1/b1mdel.c b/src/spicelib/devices/bsim1/b1mdel.c index dd702a7ae..6e2d3251b 100644 --- a/src/spicelib/devices/bsim1/b1mdel.c +++ b/src/spicelib/devices/bsim1/b1mdel.c @@ -13,7 +13,6 @@ int B1mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ B1mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/bsim2/b2mdel.c b/src/spicelib/devices/bsim2/b2mdel.c index dc7fd3ab0..7e1ca5c6f 100644 --- a/src/spicelib/devices/bsim2/b2mdel.c +++ b/src/spicelib/devices/bsim2/b2mdel.c @@ -13,7 +13,6 @@ int B2mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ B2mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/bsim3/b3mdel.c b/src/spicelib/devices/bsim3/b3mdel.c index e07950825..d3a80dfb0 100644 --- a/src/spicelib/devices/bsim3/b3mdel.c +++ b/src/spicelib/devices/bsim3/b3mdel.c @@ -18,7 +18,6 @@ int BSIM3mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -32,13 +31,11 @@ BSIM3mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/bsim3soi_dd/b3soiddmdel.c b/src/spicelib/devices/bsim3soi_dd/b3soiddmdel.c index 88dcbeaa0..f7ae9cf41 100644 --- a/src/spicelib/devices/bsim3soi_dd/b3soiddmdel.c +++ b/src/spicelib/devices/bsim3soi_dd/b3soiddmdel.c @@ -21,7 +21,6 @@ int B3SOIDDmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -35,13 +34,11 @@ B3SOIDDmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/bsim3soi_fd/b3soifdmdel.c b/src/spicelib/devices/bsim3soi_fd/b3soifdmdel.c index 8a0813c5e..b64291182 100644 --- a/src/spicelib/devices/bsim3soi_fd/b3soifdmdel.c +++ b/src/spicelib/devices/bsim3soi_fd/b3soifdmdel.c @@ -20,7 +20,6 @@ int B3SOIFDmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -34,13 +33,11 @@ B3SOIFDmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/bsim3soi_pd/b3soipdmdel.c b/src/spicelib/devices/bsim3soi_pd/b3soipdmdel.c index df1e74ec7..850dcb3a6 100644 --- a/src/spicelib/devices/bsim3soi_pd/b3soipdmdel.c +++ b/src/spicelib/devices/bsim3soi_pd/b3soipdmdel.c @@ -20,7 +20,6 @@ int B3SOIPDmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -34,13 +33,11 @@ B3SOIPDmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/bsim3v0/b3v0mdel.c b/src/spicelib/devices/bsim3v0/b3v0mdel.c index f400a8ef7..aafe30f4b 100644 --- a/src/spicelib/devices/bsim3v0/b3v0mdel.c +++ b/src/spicelib/devices/bsim3v0/b3v0mdel.c @@ -14,7 +14,6 @@ int BSIM3v0mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -28,13 +27,11 @@ BSIM3v0mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/bsim3v1/b3v1mdel.c b/src/spicelib/devices/bsim3v1/b3v1mdel.c index 6faf2bc9b..f0dd5e06c 100644 --- a/src/spicelib/devices/bsim3v1/b3v1mdel.c +++ b/src/spicelib/devices/bsim3v1/b3v1mdel.c @@ -20,7 +20,6 @@ int BSIM3v1mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -34,13 +33,11 @@ BSIM3v1mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/bsim3v32/b3v32mdel.c b/src/spicelib/devices/bsim3v32/b3v32mdel.c index 6aeb40903..f98592b08 100644 --- a/src/spicelib/devices/bsim3v32/b3v32mdel.c +++ b/src/spicelib/devices/bsim3v32/b3v32mdel.c @@ -19,7 +19,6 @@ int BSIM3v32mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -33,13 +32,11 @@ BSIM3v32mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/bsim4/b4mdel.c b/src/spicelib/devices/bsim4/b4mdel.c index 8ece1c5d1..48183a3a7 100644 --- a/src/spicelib/devices/bsim4/b4mdel.c +++ b/src/spicelib/devices/bsim4/b4mdel.c @@ -68,7 +68,6 @@ int BSIM4mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -82,13 +81,11 @@ BSIM4mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/bsim4v5/b4v5mdel.c b/src/spicelib/devices/bsim4v5/b4v5mdel.c index 8a4166c8e..5decf880c 100644 --- a/src/spicelib/devices/bsim4v5/b4v5mdel.c +++ b/src/spicelib/devices/bsim4v5/b4v5mdel.c @@ -18,7 +18,6 @@ int BSIM4v5mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -32,13 +31,11 @@ BSIM4v5mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/bsim4v6/b4v6mdel.c b/src/spicelib/devices/bsim4v6/b4v6mdel.c index e5652e31e..6f5f96ab9 100644 --- a/src/spicelib/devices/bsim4v6/b4v6mdel.c +++ b/src/spicelib/devices/bsim4v6/b4v6mdel.c @@ -20,7 +20,6 @@ int BSIM4v6mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -34,13 +33,11 @@ BSIM4v6mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/bsim4v7/b4v7mdel.c b/src/spicelib/devices/bsim4v7/b4v7mdel.c index 6b5bfb950..e25bc5ce5 100644 --- a/src/spicelib/devices/bsim4v7/b4v7mdel.c +++ b/src/spicelib/devices/bsim4v7/b4v7mdel.c @@ -20,7 +20,6 @@ int BSIM4v7mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -34,13 +33,11 @@ BSIM4v7mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/bsimsoi/b4soimdel.c b/src/spicelib/devices/bsimsoi/b4soimdel.c index 69e7ebea7..64276fb1c 100644 --- a/src/spicelib/devices/bsimsoi/b4soimdel.c +++ b/src/spicelib/devices/bsimsoi/b4soimdel.c @@ -24,7 +24,6 @@ int B4SOImDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -38,13 +37,11 @@ B4SOImDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/cap/capmdel.c b/src/spicelib/devices/cap/capmdel.c index 719f91a9e..8d81f36e9 100644 --- a/src/spicelib/devices/cap/capmdel.c +++ b/src/spicelib/devices/cap/capmdel.c @@ -14,7 +14,6 @@ int CAPmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -28,13 +27,11 @@ CAPmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/cccs/cccsmdel.c b/src/spicelib/devices/cccs/cccsmdel.c index fe60b23ea..e9f515bb2 100644 --- a/src/spicelib/devices/cccs/cccsmdel.c +++ b/src/spicelib/devices/cccs/cccsmdel.c @@ -13,7 +13,6 @@ int CCCSmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ CCCSmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/ccvs/ccvsmdel.c b/src/spicelib/devices/ccvs/ccvsmdel.c index 05de77b46..278120f61 100644 --- a/src/spicelib/devices/ccvs/ccvsmdel.c +++ b/src/spicelib/devices/ccvs/ccvsmdel.c @@ -13,7 +13,6 @@ int CCVSmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ CCVSmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/cpl/cplmdel.c b/src/spicelib/devices/cpl/cplmdel.c index 3a372e901..5e2bf7b68 100644 --- a/src/spicelib/devices/cpl/cplmdel.c +++ b/src/spicelib/devices/cpl/cplmdel.c @@ -15,7 +15,6 @@ int CPLmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -29,13 +28,11 @@ CPLmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/csw/cswmdel.c b/src/spicelib/devices/csw/cswmdel.c index 6b948bfb2..7f189ba04 100644 --- a/src/spicelib/devices/csw/cswmdel.c +++ b/src/spicelib/devices/csw/cswmdel.c @@ -13,7 +13,6 @@ int CSWmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ CSWmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/dio/diomdel.c b/src/spicelib/devices/dio/diomdel.c index eadefbc5e..e52740094 100644 --- a/src/spicelib/devices/dio/diomdel.c +++ b/src/spicelib/devices/dio/diomdel.c @@ -13,7 +13,6 @@ int DIOmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ DIOmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/hfet1/hfetmdel.c b/src/spicelib/devices/hfet1/hfetmdel.c index aab2f7842..92be848a7 100644 --- a/src/spicelib/devices/hfet1/hfetmdel.c +++ b/src/spicelib/devices/hfet1/hfetmdel.c @@ -17,7 +17,6 @@ int HFETAmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -31,13 +30,11 @@ HFETAmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/hfet2/hfet2mdel.c b/src/spicelib/devices/hfet2/hfet2mdel.c index bec8cf033..ce7a26bbc 100644 --- a/src/spicelib/devices/hfet2/hfet2mdel.c +++ b/src/spicelib/devices/hfet2/hfet2mdel.c @@ -17,7 +17,6 @@ int HFET2mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -31,13 +30,11 @@ HFET2mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/hisim2/hsm2mdel.c b/src/spicelib/devices/hisim2/hsm2mdel.c index 34b54f538..f3e556e00 100644 --- a/src/spicelib/devices/hisim2/hsm2mdel.c +++ b/src/spicelib/devices/hisim2/hsm2mdel.c @@ -64,7 +64,6 @@ int HSM2mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -78,13 +77,11 @@ HSM2mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/hisimhv1/hsmhvmdel.c b/src/spicelib/devices/hisimhv1/hsmhvmdel.c index f94910cd3..ebb509869 100644 --- a/src/spicelib/devices/hisimhv1/hsmhvmdel.c +++ b/src/spicelib/devices/hisimhv1/hsmhvmdel.c @@ -25,7 +25,6 @@ int HSMHVmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -39,13 +38,11 @@ HSMHVmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/hisimhv2/hsmhv2mdel.c b/src/spicelib/devices/hisimhv2/hsmhv2mdel.c index 4256ed07b..8d8bfcf2f 100644 --- a/src/spicelib/devices/hisimhv2/hsmhv2mdel.c +++ b/src/spicelib/devices/hisimhv2/hsmhv2mdel.c @@ -67,7 +67,6 @@ int HSMHV2mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -81,13 +80,11 @@ HSMHV2mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/ind/indmdel.c b/src/spicelib/devices/ind/indmdel.c index bec3c3418..e63a33e1c 100644 --- a/src/spicelib/devices/ind/indmdel.c +++ b/src/spicelib/devices/ind/indmdel.c @@ -13,7 +13,6 @@ int INDmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ INDmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/ind/mutmdel.c b/src/spicelib/devices/ind/mutmdel.c index dd383cc27..79edfc03b 100644 --- a/src/spicelib/devices/ind/mutmdel.c +++ b/src/spicelib/devices/ind/mutmdel.c @@ -14,7 +14,6 @@ int MUTmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -28,13 +27,11 @@ MUTmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/isrc/isrcmdel.c b/src/spicelib/devices/isrc/isrcmdel.c index aaa4ca293..e4275f492 100644 --- a/src/spicelib/devices/isrc/isrcmdel.c +++ b/src/spicelib/devices/isrc/isrcmdel.c @@ -13,7 +13,6 @@ int ISRCmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ ISRCmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/jfet/jfetmdel.c b/src/spicelib/devices/jfet/jfetmdel.c index 5f92256ec..c1043e130 100644 --- a/src/spicelib/devices/jfet/jfetmdel.c +++ b/src/spicelib/devices/jfet/jfetmdel.c @@ -13,7 +13,6 @@ int JFETmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ JFETmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/jfet2/jfet2mdel.c b/src/spicelib/devices/jfet2/jfet2mdel.c index e3d546699..191d9d21f 100644 --- a/src/spicelib/devices/jfet2/jfet2mdel.c +++ b/src/spicelib/devices/jfet2/jfet2mdel.c @@ -17,7 +17,6 @@ int JFET2mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -31,13 +30,11 @@ JFET2mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/ltra/ltramdel.c b/src/spicelib/devices/ltra/ltramdel.c index 0fe5bac7b..b7784e9e4 100644 --- a/src/spicelib/devices/ltra/ltramdel.c +++ b/src/spicelib/devices/ltra/ltramdel.c @@ -13,7 +13,6 @@ int LTRAmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ LTRAmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/mes/mesmdel.c b/src/spicelib/devices/mes/mesmdel.c index c225ce7c8..bfe5dc38e 100644 --- a/src/spicelib/devices/mes/mesmdel.c +++ b/src/spicelib/devices/mes/mesmdel.c @@ -13,7 +13,6 @@ int MESmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ MESmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/mesa/mesamdel.c b/src/spicelib/devices/mesa/mesamdel.c index e9db68df4..be32a4942 100644 --- a/src/spicelib/devices/mesa/mesamdel.c +++ b/src/spicelib/devices/mesa/mesamdel.c @@ -17,7 +17,6 @@ int MESAmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -31,13 +30,11 @@ MESAmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/mos1/mos1mdel.c b/src/spicelib/devices/mos1/mos1mdel.c index be90fe7bc..d94c4edd6 100644 --- a/src/spicelib/devices/mos1/mos1mdel.c +++ b/src/spicelib/devices/mos1/mos1mdel.c @@ -13,7 +13,6 @@ int MOS1mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ MOS1mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/mos2/mos2mdel.c b/src/spicelib/devices/mos2/mos2mdel.c index 232bf3841..858dea08d 100644 --- a/src/spicelib/devices/mos2/mos2mdel.c +++ b/src/spicelib/devices/mos2/mos2mdel.c @@ -13,7 +13,6 @@ int MOS2mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ MOS2mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/mos3/mos3mdel.c b/src/spicelib/devices/mos3/mos3mdel.c index 94dcc26c5..3b171adcd 100644 --- a/src/spicelib/devices/mos3/mos3mdel.c +++ b/src/spicelib/devices/mos3/mos3mdel.c @@ -13,7 +13,6 @@ int MOS3mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ MOS3mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/mos9/mos9mdel.c b/src/spicelib/devices/mos9/mos9mdel.c index cb9cd07df..633f5ea62 100644 --- a/src/spicelib/devices/mos9/mos9mdel.c +++ b/src/spicelib/devices/mos9/mos9mdel.c @@ -14,7 +14,6 @@ int MOS9mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -28,13 +27,11 @@ MOS9mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/numd/numdmdel.c b/src/spicelib/devices/numd/numdmdel.c index e206b98ab..9b1f0791b 100644 --- a/src/spicelib/devices/numd/numdmdel.c +++ b/src/spicelib/devices/numd/numdmdel.c @@ -13,7 +13,6 @@ int NUMDmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ NUMDmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/numd2/nud2mdel.c b/src/spicelib/devices/numd2/nud2mdel.c index 4386cf9e3..a413a53e5 100644 --- a/src/spicelib/devices/numd2/nud2mdel.c +++ b/src/spicelib/devices/numd2/nud2mdel.c @@ -13,7 +13,6 @@ int NUMD2mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ NUMD2mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/res/resmdel.c b/src/spicelib/devices/res/resmdel.c index aa8874fa9..37d7d8958 100644 --- a/src/spicelib/devices/res/resmdel.c +++ b/src/spicelib/devices/res/resmdel.c @@ -13,7 +13,6 @@ int RESmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ RESmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/soi3/soi3mdel.c b/src/spicelib/devices/soi3/soi3mdel.c index 93737e0f5..ee88347e0 100644 --- a/src/spicelib/devices/soi3/soi3mdel.c +++ b/src/spicelib/devices/soi3/soi3mdel.c @@ -30,7 +30,6 @@ int SOI3mDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -44,13 +43,11 @@ SOI3mDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/sw/swmdel.c b/src/spicelib/devices/sw/swmdel.c index eadd84ff8..e38d6877c 100644 --- a/src/spicelib/devices/sw/swmdel.c +++ b/src/spicelib/devices/sw/swmdel.c @@ -13,7 +13,6 @@ int SWmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ SWmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/tra/tramdel.c b/src/spicelib/devices/tra/tramdel.c index 542ae4efd..93f3c9151 100644 --- a/src/spicelib/devices/tra/tramdel.c +++ b/src/spicelib/devices/tra/tramdel.c @@ -13,7 +13,6 @@ int TRAmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ TRAmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/txl/txlmdel.c b/src/spicelib/devices/txl/txlmdel.c index a36c3426b..d5aef93ef 100644 --- a/src/spicelib/devices/txl/txlmdel.c +++ b/src/spicelib/devices/txl/txlmdel.c @@ -14,7 +14,6 @@ int TXLmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -28,13 +27,11 @@ TXLmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/urc/urcmdel.c b/src/spicelib/devices/urc/urcmdel.c index 5a99d9c33..ba6db3427 100644 --- a/src/spicelib/devices/urc/urcmdel.c +++ b/src/spicelib/devices/urc/urcmdel.c @@ -13,7 +13,6 @@ int URCmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ URCmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/vccs/vccsmdel.c b/src/spicelib/devices/vccs/vccsmdel.c index a2020610d..f4d38c023 100644 --- a/src/spicelib/devices/vccs/vccsmdel.c +++ b/src/spicelib/devices/vccs/vccsmdel.c @@ -13,7 +13,6 @@ int VCCSmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ VCCSmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/vcvs/vcvsmdel.c b/src/spicelib/devices/vcvs/vcvsmdel.c index a87b009d3..4adc62155 100644 --- a/src/spicelib/devices/vcvs/vcvsmdel.c +++ b/src/spicelib/devices/vcvs/vcvsmdel.c @@ -13,7 +13,6 @@ int VCVSmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ VCVSmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; } diff --git a/src/spicelib/devices/vsrc/vsrcmdel.c b/src/spicelib/devices/vsrc/vsrcmdel.c index fabe7d470..42593c002 100644 --- a/src/spicelib/devices/vsrc/vsrcmdel.c +++ b/src/spicelib/devices/vsrc/vsrcmdel.c @@ -13,7 +13,6 @@ int VSRCmDelete(GENmodel **model, IFuid modname, GENmodel *kill) { GENinstance *here; - GENinstance *prev = NULL; GENmodel **oldmod; oldmod = model; @@ -27,13 +26,11 @@ VSRCmDelete(GENmodel **model, IFuid modname, GENmodel *kill) delgot: *oldmod = (*model)->GENnextModel; /* cut deleted device out of list */ - for (here = (*model)->GENinstances; here; here = here->GENnextInstance) { - if (prev) - FREE(prev); - prev = here; + for (here = (*model)->GENinstances; here;) { + GENinstance *next_instance = here->GENnextInstance; + FREE(here); + here = next_instance; } - if (prev) - FREE(prev); FREE(*model); return OK; }