Jspice3
cktdest.c
Go to the documentation of this file.
1 /***************************************************************************
2 JSPICE3 adaptation of Spice3f2 - Copyright (c) Stephen R. Whiteley 1992
3 Copyright 1990 Regents of the University of California. All rights reserved.
4 Authors: 1987 Thomas L. Quarles
5  1992 Stephen R. Whiteley
6 ****************************************************************************/
7 
8  /* CKTdestroy(ckt)
9  * this is a driver program to iterate through all the various
10  * destroy functions provided for the circuit elements in the
11  * given circuit
12  */
13 
14 #include "spice.h"
15 #include <stdio.h>
16 #include "devdefs.h"
17 #include "sperror.h"
18 #include "util.h"
19 #include "cktext.h"
20 
21 extern SPICEdev *DEVices[];
22 
23 int
24 CKTdestroy(inCkt)
25 
26 GENERIC *inCkt;
27 {
28  CKTcircuit *ckt = (CKTcircuit *)inCkt;
29  int i;
30  CKTnode *node;
31  CKTnode *nnode;
32  struct sCKTmodHead *mh, *mhnext;
33 
34 
35  for (i = 0; i < DEVmaxnum; i++) {
36  if ((DEVices[i]->DEVdestroy != NULL) &&
37  (ckt->CKThead[i] != NULL)) {
38  (*DEVices[i]->DEVdestroy)(&ckt->CKThead[i]);
39  }
40  }
41 
42  for (mh = ckt->CKTheadList; mh != NULL; mh = mhnext) {
43  mhnext = mh->next;
44  FREE(mh);
45  }
46 
47  for (i = 0; i <= ckt->CKTmaxOrder+1; i++) {
48  FREE(ckt->CKTstates[i]);
49  }
50 
51  if (ckt->CKTmatrix) spDestroy(ckt->CKTmatrix);
52  if (ckt->CKTbreaks) FREE(ckt->CKTbreaks);
53 
54  for (node = ckt->CKTnodes; node; ) {
55  nnode = node->next;
56  FREE(node);
57  node = nnode;
58  }
59 
60  FREE(ckt->CKTtimePoints);
61 
62  INPtablFree((GENERIC*)ckt);
63 
64  FREE(ckt);
65  return (OK);
66 }
struct sCKTmodHead * next
Definition: cktdefs.h:58
SMPmatrix * CKTmatrix
Definition: cktdefs.h:95
#define FREE(ptr)
Definition: spdefs.h:436
int CKTmaxOrder
Definition: cktdefs.h:88
#define OK
Definition: iferrmsg.h:17
void INPtablFree()
struct sCKTmodHead * CKTheadList
Definition: cktdefs.h:63
void(* DEVdestroy)()
Definition: devdefs.h:100
#define NULL
Definition: spdefs.h:121
struct sCKTnode * next
Definition: cktdefs.h:43
CKTnode * CKTnodes
Definition: cktdefs.h:135
double * CKTstates[8]
Definition: cktdefs.h:68
int CKTdestroy(GENERIC *inCkt)
Definition: cktdest.c:24
double * CKTtimePoints
Definition: cktdefs.h:218
void spDestroy()
double * CKTbreaks
Definition: cktdefs.h:179
SPICEdev * DEVices[]
Definition: sconfig.c:109
GENmodel * CKThead[MAXNUMDEVS]
Definition: cktdefs.h:64
int DEVmaxnum
Definition: sconfig.c:166
char GENERIC
Definition: ifsim.h:27