1 /**********
2 Copyright 1990 Regents of the University of California. All rights reserved.
3 Author: 1985 Thomas L. Quarles
4 **********/
5
6 /* CKTdltMod
7 * delete the specified model - not yet supported in spice
8 */
9
10 #include "ngspice/ngspice.h"
11 #include "ngspice/cktdefs.h"
12 #include "ngspice/ifsim.h"
13 #include "ngspice/sperror.h"
14
15
16
17 /* ARGSUSED */
18 int
CKTdltMod(CKTcircuit * ckt,GENmodel * m)19 CKTdltMod(CKTcircuit *ckt, GENmodel *m)
20 {
21 GENmodel *mod, **prevp;
22 GENinstance *h, *next_i;
23 int error;
24
25 prevp = &ckt->CKThead[m->GENmodType];
26 for (mod = *prevp; m && mod != m; mod = mod->GENnextModel)
27 prevp = &mod->GENnextModel;
28
29 if (!mod)
30 return OK;
31
32 *prevp = m->GENnextModel;
33
34 for (h = m->GENinstances; h; h = next_i) {
35 next_i = h->GENnextInstance;
36 if (h != nghash_delete(ckt->DEVnameHash, h->GENname))
37 fprintf(stderr, "ERROR, ouch nasal daemons ...\n");
38 error = SPfrontEnd->IFdelUid (ckt, h->GENname,
39 UID_INSTANCE);
40 GENinstanceFree(h);
41 }
42 if (m != nghash_delete(ckt->MODnameHash, m->GENmodName))
43 fprintf(stderr, "ERROR, ouch nasal daemons ...\n");
44 error = SPfrontEnd->IFdelUid (ckt, m->GENmodName, UID_MODEL);
45 GENmodelFree(m);
46 return(OK);
47 }
48