Browse Source

DEVdestroy(), change API, #2/2, complete the change, inclusive CKTdestroy()

loop over DEVmodDelete() and DEVdelete() in CKTdestroy()
  instead of doing this business in the DEVdestroy() functions.

As a consequence, most DEVdestroy() functions
  collapse completely.
pre-master-46
rlar 8 years ago
parent
commit
4748c92de9
  1. 4
      src/include/ngspice/devdefs.h
  2. 2
      src/include/ngspice/dllitf.h
  3. 2
      src/include/ngspice/mifproto.h
  4. 25
      src/spicelib/analysis/cktdest.c
  5. 17
      src/spicelib/devices/adms/admst/ngspiceMODULEdest.c.xml
  6. 2
      src/spicelib/devices/adms/admst/ngspiceMODULEext.h.xml
  7. 18
      src/spicelib/devices/asrc/asrcdest.c
  8. 4
      src/xspice/icm/dlmain.c
  9. 29
      src/xspice/mif/mifdestr.c

4
src/include/ngspice/devdefs.h

@ -69,8 +69,8 @@ typedef struct SPICEdev {
/* ac analysis loading function */
int (*DEVaccept)(CKTcircuit*,GENmodel*);
/* subroutine to call on acceptance of a timepoint */
void (*DEVdestroy)(GENmodel**);
/* subroutine to destroy all models and instances */
void (*DEVdestroy)(void);
/* subroutine to delete device specfic extra data */
int (*DEVmodDelete)(GENmodel*);
/* subroutine to delete a model */
int (*DEVdelete)(GENinstance*);

2
src/include/ngspice/dllitf.h

@ -28,7 +28,7 @@ struct coreInfo_t {
int ((*dllitf_MIFconvTest)(GENmodel *, CKTcircuit *));
int ((*dllitf_MIFdelete)(GENinstance *));
int ((*dllitf_MIFmDelete)(GENmodel *));
void ((*dllitf_MIFdestroy)(GENmodel **));
void ((*dllitf_MIFdestroy)(void));
char * ((*dllitf_MIFgettok)(char **));
char * ((*dllitf_MIFget_token)(char **, Mif_Token_Type_t *));
Mif_Cntl_Src_Type_t ((*dllitf_MIFget_cntl_src_type)(Mif_Port_Type_t, Mif_Port_Type_t));

2
src/include/ngspice/mifproto.h

@ -133,7 +133,7 @@ extern int MIFmDelete(
);
extern void MIFdestroy(
GENmodel **inModel
void
);
extern char *MIFgettok(

25
src/spicelib/analysis/cktdest.c

@ -37,11 +37,28 @@ CKTdestroy(CKTcircuit *ckt)
}
#endif
for (i=0;i<DEVmaxnum;i++) {
if ( DEVices[i] && DEVices[i]->DEVdestroy && ckt->CKThead[i] ) {
DEVices[i]->DEVdestroy (&(ckt->CKThead[i]));
for (i = 0; i < DEVmaxnum; i++)
if (DEVices[i]) {
GENmodel *model = ckt->CKThead[i];
while (model) {
GENmodel *next_model = model->GENnextModel;
GENinstance *inst = model->GENinstances;
while (inst) {
GENinstance *next_inst = inst->GENnextInstance;
if (DEVices[i]->DEVdelete)
DEVices[i]->DEVdelete(inst);
FREE(inst);
inst = next_inst;
}
if (DEVices[i]->DEVmodDelete)
DEVices[i]->DEVmodDelete(model);
FREE(model);
model = next_model;
}
if (DEVices[i]->DEVdestroy)
DEVices[i]->DEVdestroy();
}
}
for(i=0;i<=ckt->CKTmaxOrder+1;i++){
FREE(ckt->CKTstates[i]);
}

17
src/spicelib/devices/adms/admst/ngspiceMODULEdest.c.xml

@ -45,23 +45,8 @@
#include &quot;ngspice/suffix.h&quot;
void
$(module)destroy(GENmodel **inModel)
$(module)destroy(void)
{
$(module)model *mod = *($(module)model**) inModel;
while (mod) {
$(module)model *next_mod = mod->$(module)nextModel;
$(module)instance *inst = mod->$(module)instances;
while (inst) {
$(module)instance *next_inst = inst-&gt;$(module)nextInstance;
FREE(inst);
inst = next_inst;
}
FREE(mod);
mod = next_mod;
}
*inModel = NULL;
}
</admst:template>

2
src/spicelib/devices/adms/admst/ngspiceMODULEext.h.xml

@ -51,7 +51,7 @@ extern int $(module)noise(int,int,GENmodel*,CKTcircuit*,Ndata*,double*);
extern int $(module)pzLoad(GENmodel*,CKTcircuit*,SPcomplex*);
extern int $(module)trunc(GENmodel*,CKTcircuit*,double*);
extern int $(module)unsetup(GENmodel*,CKTcircuit*);
extern void $(module)destroy(GENmodel**);
extern void $(module)destroy(void);
#endif

18
src/spicelib/devices/asrc/asrcdest.c

@ -9,25 +9,9 @@ Author: 1987 Kanwar Jit Singh
void
ASRCdestroy(GENmodel **inModel)
ASRCdestroy(void)
{
ASRCmodel *mod = *(ASRCmodel**) inModel;
while (mod) {
ASRCmodel *next_mod = mod->ASRCnextModel;
ASRCinstance *inst = mod->ASRCinstances;
while (inst) {
ASRCinstance *next_inst = inst->ASRCnextInstance;
FREE(inst);
inst = next_inst;
}
FREE(mod);
mod = next_mod;
}
FREE(asrc_vals);
FREE(asrc_derivs);
asrc_nvals = 0;
*inModel = NULL;
}

4
src/xspice/icm/dlmain.c

@ -209,9 +209,9 @@ int MIFmDelete(
}
void MIFdestroy(
GENmodel **inModel
void
) {
(coreitf->dllitf_MIFdestroy)(inModel);
(coreitf->dllitf_MIFdestroy)();
}
char *MIFgettok(

29
src/xspice/mif/mifdestr.c

@ -49,35 +49,8 @@ NON-STANDARD FEATURES
/*
MIFdestroy
This function deletes all models and all instances of a specified
device type. It traverses the linked list of model structures
for that type and calls MIFmDelete on each model.
*/
void MIFdestroy(
GENmodel **inModel) /* The head of the list of models to delete */
void MIFdestroy(void)
{
/* Free all models of this device type by removing */
/* models from the head of the linked list until */
/* the head is null */
GENmodel *model = *inModel;
while (model) {
GENmodel *next_model = model->GENnextModel;
GENinstance *inst = model->GENinstances;
while (inst) {
GENinstance *next_instance = inst->GENnextInstance;
MIFdelete(inst);
FREE(inst);
inst = next_instance;
}
MIFmDelete(model);
FREE(model);
model = next_model;
}
*inModel = NULL;
}
Loading…
Cancel
Save